如何删除复选框内的复选标记周围的矩形(Android)

时间:2012-06-21 14:39:23

标签: android

有没有办法删除围绕android中的复选框的矩形?我想只保留复选标记,而不是矩形。

2 个答案:

答案 0 :(得分:0)

您可以使用自定义复选框xml文件。尝试下面的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/cbchk_blue"
    android:state_focused="false">
    <shape android:shape="rectangle">
        <stroke android:width="2dp" android:color="@color/blue_dark" />
        <gradient  android:endColor="@color/white" android:startColor="@color/blue_dark" android:type="sweep"  />
        <size android:height="30dp" android:width="30dp" />
    </shape>
</item>
<item android:state_checked="true" 
    android:drawable="@drawable/cbchk_blue"
    android:state_focused="true">
    <shape android:shape="rectangle">
        <stroke android:width="2dp" android:color="@color/white" />
        <gradient  android:endColor="@color/white" android:startColor="@color/blue_dark" android:type="sweep"  />
        <size android:height="30dp" android:width="30dp" />
    </shape>
</item>
<item android:state_checked="false" 
    android:drawable="@drawable/cbunchk_blue"
    android:state_focused="false">
    <shape android:shape="rectangle">
        <stroke android:width="2dp" android:color="@color/blue_dark" />
        <size android:height="30dp" android:width="30dp" />
    </shape>
</item>
<item android:state_checked="false" 
    android:drawable="@drawable/cbunchk_blue"
    android:state_focused="true">
    <shape android:shape="rectangle">
        <stroke android:width="2dp" android:color="@color/white" />
        <size android:height="30dp" android:width="30dp" />
    </shape>
</item>

将图像保存为cbchk_blue,并将其放置在可绘制的文件夹中。

enter image description here

答案 1 :(得分:0)

在xml

中添加透明背景到复选框
<CheckBox
   android:background="@android:color/transparent"
   android:button="@drawable/your_checkbox"/>