custom_checkbox.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:andro>

    <item android:drawable="@drawable/btn_unselect" android:state_checked="false"/>
    <item android:drawable="@drawable/btn_select" android:state_checked="true"/>

</selector>

styles.xml中

    <style name="custom_checkbox" parent="@android:style/Widget.CompoundButton.CheckBox">
        <item name="android:button">@drawable/custom_checkbox</item>
    </style>

 

Checkbox:

   <CheckBox  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content"  
        android:checked="true"
        android:text="全(不)选"
        android:layout_margin="10dip"
        android:paddingLeft="10dip"
        android:textSize="20sp"
        style="@style/custom_checkbox"
        android:textColor="@color/black"/> 

备注:

paddingLeft为左边的图标与右边的文字之间的距离

相关文章:

  • 2021-05-13
  • 2022-12-23
  • 2021-08-13
  • 2022-02-17
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
猜你喜欢
  • 2022-01-25
  • 2022-12-23
  • 2021-08-01
  • 2022-02-12
相关资源
相似解决方案