矩形绘制不会显示为复选框选择项目 [英] Rectangle shape drawable won't show as checkbox selector item
本文介绍了矩形绘制不会显示为复选框选择项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经定义的矩形绘制这样的:
I have defined a rectangle drawable like this:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dip"/>
<solid android:color="#FF000000" />
<stroke android:width="1dip" android:color="@color/service_checkbox_disabled_unchecked_stroke" />
</shape>
我可以毫无问题显示drawble为ImageView的。然而,它被认为是对一个复选框之一的状态的drawble。我对复选框按钮选择是这样定义的:
I can display the drawble as imageView without problems. However, it is supposed to be a drawble for one state of a checkbox. My selector for the checkbox button is defined like this:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true" android:drawable="@drawable/bg_services_tick_unchecked_disabled" />
<item android:state_checked="false" android:drawable="@drawable/bg_services_tick_unchecked_disabled" />
</selector>
最后我复选框:
<CheckBox
android:id="@+id/cb_tariff_3_next_month_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/checkbox_services"
android:layout_centerHorizontal="true"/>
谁能告诉,为什么不是工作?非常感谢你。
Can anyone tell, why does that not work? Thank you very much.
推荐答案
您必须大小节点添加到形状:
You must add a size node to the shape:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<size android:width="30dp" android:height="30dp" />
<solid android:color="@color/blueBase"/>
<stroke
android:width="1dp"
android:color="@color/blueDark" />
</shape>
这篇关于矩形绘制不会显示为复选框选择项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文