2016-11-09 29 views
0

我已经为它创建了自定义复选框和自定义样式。但是,当我向复选框添加颜色或半径时,它将颜色或半径应用于复选框的文本以及框本身。如何将半径添加到Android中的复选框中

如何将radius添加到复选框,而不是添加到我的自定义Java类(扩展CheckBox)或样式中的文本?

回答

0

可以在this答案使用自定义绘制的CheckBox图像,如:

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

确保您的复选框是这样

android:button="@drawable/checkbox_selector" 

<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" /> 

that教程。

相关问题