2013-01-19 67 views

回答

2

创建一个选择的XML文件像这样:你不得不削减这个图像并保存为yellow_show名字和你不得不削减这个盒子的唯一方没有勾选并保存图像作为yellow_hide另一个图像..

<?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/yellow_hide" /> 
    <item android:state_checked="false" android:drawable="@drawable/yellow_show" /> 
</selector> 

将此xml文件保存在res \ drawables \文件夹中。然后在您的布局文件中将其应用到您的复选框,如下所示:

<CheckBox 
    android:text="Custom CheckBox" 
    android:button="@drawable/checkbox_selector" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/>