Seletor

유시현·2023년 1월 2일
0

Android

목록 보기
16/34

버튼 이미지 변경

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/ic_baseline_auto_fix_high_24" android:state_pressed="true"/>
    <item android:drawable="@drawable/ic_baseline_auto_fix_normal_24"/>
</selector>

기본상태와 pressed 상태를 만든다. 이때 밑에가 기본 상태가 되게해야한다.
코드를 위해서 밑으로 읽어서

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/ic_baseline_auto_fix_normal_24"/>
    <item android:drawable="@drawable/ic_baseline_auto_fix_high_24" android:state_pressed="true"/>

</selector>

이렇게 되면 계속 normal 상태가 된다

버튼 배경색 변경

res 밑에 color 리소스 디렉토리 만들고 색상 설정하고

backgroundTint 사용하면된다

profile
안드로이드 ,ios 공부하고 있습니다

0개의 댓글