zoukankan      html  css  js  c++  java
  • Android中自定义Checkbox

    custom_checkbox.xml文件:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    
        <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为左边的图标与右边的文字之间的距离
  • 相关阅读:
    记录一下过孔和通孔焊盘
    资料分享
    oracle 配置服务端
    oracle 安装
    jquery之遍历展示title
    jquery之radio
    java基础之正则表达式
    java基础之IO流
    java基础之泛型
    java基础之反射
  • 原文地址:https://www.cnblogs.com/xiaoxian1369/p/4156385.html
Copyright © 2011-2022 走看看