Android - Checkbox 預設圖示變更

Android - Checkbox 預設圖示變更

因為有使用原生Checkbox

參考網路文章

http://stackoverflow.com/questions/7783787/how-to-change-default-images-of-checkbox

要改版原生圖示依下方式改寫

drawable xml

<?xml version="1.0" encoding="utf-8"?>
<selector  xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:state_checked="false" android:drawable="@drawable/unchecked_drawable" />
     <item android:state_checked="true" android:drawable="@drawable/checked_drawable" />
     <item android:drawable="@drawable/unchecked_drawable" /> <!-- default state -->
</selector>

layout xml

<CheckBox
    android:id="@+id/chk"
    android:button="@drawable/customdrawablecheckbox"
    android:layout_alignParentLeft="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />