zoukankan      html  css  js  c++  java
  • 【Android学习】自定义checkbox

    1.1 自定义checkbox 选中图片

    自定义checkbox使用的时android:background而不是android:button,原因在于使用button时自定义图片过大超出边缘部分会截断,而使用background时会自由拉伸。

    1.1.1 自定义button图片

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

    1.1.1 自定义checkbox样式

       

    <style name="VideoDownloadCheckbox" parent="@android:style/Widget.CompoundButton.CheckBox">
        <item name="android:button">@null</item>
        <item name="android:background">@drawable/usercenter_delete_selector</item>
    </style>

    1.1.3 使用

    <CheckBox
        android:layout_width="25dp"
        android:layout_height="25dp"
        style="@style/VideoDownloadCheckbox" />
     
  • 相关阅读:
    kubuntu设置
    odoo git环境搭建
    ubuntu Gnome 14.10添加打印机
    ubuntu 14.10安装Balsamiq Mockups
    elementary os luna安装配置
    OpenERP QWeb模板标签笔记
    pycharm3 注册码
    统计项目代码
    odoo filter 日期
    opencart 安装
  • 原文地址:https://www.cnblogs.com/six-moon/p/4717530.html
Copyright © 2011-2022 走看看