">

CheckBox 이미지 변경하기


체크박스의 이미지를 변경하기 위해 selector을 이용한다. 


1. selector을 xml 파일을 새로 만들어 drawable 폴더에 넣는다. 


check_box.xml

<!--?xml version="1.0" encoding="utf-8"?--> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:drawable="@drawable/이미지파일 (체크상태)">
 <item android:state_checked="false" android:drawable="@drawable/이미지파일 (체크상태)"> <item android:drawable="@drawable/이미지파일 (비체크상태)"> </selector>


2. checkbox가 있는 layout에서 selector을 지정한다. button에다 적용하면 된다. 

<CheckBox
     android:layout_height="wrap_content"
     
     android:layout_width="wrap_content"
     android:button="@drawable/check_box”/>


+ Recent posts