如何申请自定义图像中的Andr​​oid到复选框 [英] How to apply custom image to checkbox in android

查看:119
本文介绍了如何申请自定义图像中的Andr​​oid到复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要应用自定义图像中的Andr​​oid到复选框,为了这个,我创建一个 check_custom.xml 文件中,我定义自定义图像的复选框不同状态这样的:

I'm trying to apply custom image to checkbox in android, for this I create an check_custom.xml file in which I define custom image for different states of check box like:

<item android:state_checked="true" 
      android:drawable="@drawable/btn_check_on" /> <!-- checked --> 
<item android:state_checked="false" 
      android:drawable="@drawable/btn_check_off" /> <!-- unchecked --> 
<item android:state_focused="true"
      android:drawable="@drawable/btn_check_onfocus" />    <!--on focus--> 
<item android:drawable="@drawable/btn_check_off" /> <!-- default --> 

在检查,焦点和选中的三种状态三种不同的图像, 然后我将这个XML文件的复选框的背景属性,但我没有得到需要的结果,这种技术应用自定义图像,以及默认设置情况下的图像。

Three different images on three states on checked,on focus and on unchecked, and then I assign this xml file to background attribute of check boxes,but I'm not getting required result, this technique apply the custom image as well as default image both.

推荐答案

萨尔曼,设置安卓按钮而不是安卓背景。另请参见自定义复选框形象的Andr​​oid

Salman, set android:button instead of android:background. See also Custom checkbox image android

这篇关于如何申请自定义图像中的Andr​​oid到复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆