zoukankan      html  css  js  c++  java
  • Android之自己定义checkbox样式

    大部分情况下,我们在UI中并不採用android自带的checkbox复选框样式,这时候就须要我们自己定义自己的checkbox。


    首先找两张checkbox背景图片。比方下图样子的:



    然后在drawable文件夹下定义一个背景图片xml文件,内容例如以下:

    <?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/fuxuan_input01" />
        <item android:state_selected="true" android:drawable="@drawable/fuxuan_input01"></item>
        <item android:state_pressed="true" android:drawable="@drawable/fuxuan_input01"></item>
        <item android:state_checked="false" android:drawable="@drawable/fuxuan_input02" />
    </selector>


    在须要用到checkbox的地方定义它。属性设置例如以下代码所看到的:

            <CheckBox
                android:id="@+id/agree_provision_chk"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/chk_agee_provision_background"
                android:button="@null" />

    自己定义checkbox就此完毕,效果例如以下图所看到的:


  • 相关阅读:
    postgresql删除活动链接的数据库
    第四篇 函数
    Jmeter响应中文乱码解决办法
    第三篇 条件控制和循环
    第二篇 Python运算符
    npm更换为镜像
    第一篇 Python的数据类型
    newman的常用命令使用总结
    windows下安装newman
    同态包络提取
  • 原文地址:https://www.cnblogs.com/tlnshuju/p/6782882.html
Copyright © 2011-2022 走看看