2014-11-01 61 views
0

我使用如何在Android中禁用复选框按钮4.0

android:button="@null" 

在复选框失效按钮,它在4.2上工作的罚款,但它不是在4.0(冰淇淋三明治工作)。

它的外观在4.0(冰淇淋三明治)

enter image description here

如何它看起来在上版本。

enter image description here

我的XML类。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" > 

<com.search.Monthcheckbox 
    android:id="@+id/ch1" 
    android:layout_width="40dp" 
    android:layout_height="40dp" 
    android:layout_centerInParent="true" 
    android:layout_marginTop="10dp" 
    android:button="@null" 
    android:checked="false" 
    android:focusable="false" 
    android:gravity="center" 
    android:text="OCT" 
    android:textColor="@color/tripoto_grey" 
    android:textSize="13dp" /> 

帮我个忙。

+0

是一个*复选框*?显示您的xml – 2014-11-03 06:07:48

+0

是的,它是一个自定义复选框。 – Ankit 2014-11-03 06:10:16

+0

那么你需要检查* Monthcheckbox * – 2014-11-03 06:10:58

回答

0

创建自定义绘制和绘制的文件夹设置为android:button="@drawable/selector"

selector.xml

<?xml version="1.0" encoding="utf-8"?> 
       <selector xmlns:android="http://schemas.android.com/apk/res/android"> 
       <item android:state_checked="true" 
        android:drawable="@drawable/your_drawable" /> <!-- checked --> 
       <item android:state_checked="false" 
       android:drawable="@drawable/your_drawable" /> <!-- unchecked--> 
       </selector> 
+0

不适合我。 – Ankit 2014-11-03 06:00:36

相关问题