如何更改这样的复选框?

时间:2016-08-15 05:52:03

标签: java android checkbox

我需要更改enter image description here的复选框 到enter image description here

1 个答案:

答案 0 :(得分:0)

创建一个可绘制的custom_cheackbox:

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

在custom_checkbox android:button="@drawable/custom_cheackbox"

中添加自定义背景
<CheckBox
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:button="@drawable/checkbox_selector"
    android:text="CheckBox"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/Black" />