안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요~
CheckBox 이미지를 변경하고 싶은데 잘 되지가 않네요.
res/drawable 에다가 아래와 같이 checkbox가 체크되었을때의 이미지를 바꿔주고 나머지는 디폴트 이미지를 지정하였습니다.
<?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/ic_button_off" />
<item
android:drawable="@drawable/ic_button_on" />
</selector>
그리고 아래는 CheckBox layout입니다.
<CheckBox android:id="@id/CheckBox_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/custombtn"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="2dip" android:focusable="false" android:clickable="false"></CheckBox>
background에다가 위에서 만든 customtn을 지정하였습니다.
그러면 기존체크박스 이미지와 제가 사용하고 싶은 이미지가 겹쳐서 나옵니다.(이미지 첨부합니다.)
CheckBox를 ToggleButton으로 바꾸면 정상적으로 이미지가 하나만 나오는데.. CheckBox는 잘 되지가 않네요. ㅠ
아시는분은 뭐가 잘못되었는지 가르켜주시면 감사하겠습니다. (_ _)
CheckBox 이미지를 변경하고 싶은데 잘 되지가 않네요.
res/drawable 에다가 아래와 같이 checkbox가 체크되었을때의 이미지를 바꿔주고 나머지는 디폴트 이미지를 지정하였습니다.
<?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/ic_button_off" />
<item
android:drawable="@drawable/ic_button_on" />
</selector>
그리고 아래는 CheckBox layout입니다.
<CheckBox android:id="@id/CheckBox_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/custombtn"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="2dip" android:focusable="false" android:clickable="false"></CheckBox>
background에다가 위에서 만든 customtn을 지정하였습니다.
그러면 기존체크박스 이미지와 제가 사용하고 싶은 이미지가 겹쳐서 나옵니다.(이미지 첨부합니다.)
CheckBox를 ToggleButton으로 바꾸면 정상적으로 이미지가 하나만 나오는데.. CheckBox는 잘 되지가 않네요. ㅠ
아시는분은 뭐가 잘못되었는지 가르켜주시면 감사하겠습니다. (_ _)
CompoundButton 들은 다 저렇게 하더라구요.