android中CheckBox的高级应用之button属性

在我们普通的应用中checkBox里有多个Item时,页面中会自动为我们提供复选框的按钮,但我们有时会遇到这要的情况,CheckBox应用的对象不需要多个Item而是每个CheckBox对应平行的每一个选项,而且要求作出按钮(buuton)有CSS属性改变的效果,此时就必须要用到CheckBox的高级应用:以下是个人的一点总结,有不足的地方望大家多提宝贵意见。

 

(1)在Layout资源文件中,CheckBox的属性可以根据你人的不同用法做相应的改变,这个是我在做淘宝客户端的时候的应用,但加黑处:android:button=”资源文件中的对应属性值文件,check_but 是一个xml文件,其内容为以下所示。”

<CheckBox

       android:id="@+id/checkIn"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

       android:checked="false"

       android:focusableInTouchMode="false"

      android:button="@drawable/check_but"

      

     ></CheckBox>

 

 

Check_but.xml的内容(附有用到的变换图片 

 

<?xmlversion="1.0" encoding="utf-8"?>

<selectorxmlns:android="http://schemas.android.com/apk/res/android">

       <!--已经选中 -->

       <item android:state_window_focused="false"android:state_enabled="true"

              android:state_checked="true"android:drawable="@drawable/btn_check_on" />

              <!--未被选中 -->

       <itemandroid:state_window_focused="false"android:state_enabled="true"

              android:state_checked="false"android:drawable="@drawable/btn_check_off"></item>

       <!--已经选中,且被按下-->

       <itemandroid:state_enabled="true" android:state_checked="true"

              android:state_pressed="true"android:drawable="@drawable/btn_check_on_pressed"></item>

       <!--未被选中,且被按下-->

       <item android:state_enabled="true"android:state_checked="false"

              android:state_pressed="true"android:drawable="@drawable/btn_check_off_pressed"></item>

       <!--已经选中,且被聚焦-->

       <itemandroid:state_focused="true" android:state_enabled="true"

              android:state_checked="true"android:drawable="@drawable/btn_check_on_selected"></item>

       <!--未被选中,且被聚焦 -->

       <itemandroid:state_focused="true" android:state_enabled="true"

              android:state_checked="false"android:drawable="@drawable/btn_check_off_selected"></item>

 

</selector>

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值