码迷,mamicode.com
首页 > 移动开发 > 详细

[Android]自定义checkbox

时间:2015-08-10 11:56:50      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

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

 

 

[Android]自定义checkbox

标签:

原文地址:http://www.cnblogs.com/six-moon/p/4717530.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!