【发布时间】:2019-01-10 20:20:14
【问题描述】:
这就是我创建带边框的圆形checkbox 的方式。但是边框是方形的,而不是圆形的。
复选框
<CheckBox
android:id="@+id/checkBox"
android:paddingTop="15dp"
android:paddingRight="25dp"
android:layout_width="25dp"
android:layout_marginLeft="320dp"
android:layout_height="25dp"
android:button="@drawable/xml_button"
android:background="@drawable/xml_background"/>
xml_button
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<shape android:shape="oval">
<solid android:color="#00FF00" />
<size
android:width="24dp"
android:height="24dp" />
</shape>
</item>
<item android:state_checked="false">
<shape android:shape="oval">
<solid android:color="#AAA" />
<size
android:width="24dp"
android:height="24dp" />
</shape>
</item>
</selector>
xml_background
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="3dp" />
<stroke
android:width="2dp"
android:color="#CCC" />
<padding
android:left="34dp"
android:top="5dp"
android:right="10dp"
android:bottom="5dp" />
</shape>
输出
任何帮助将不胜感激。谢谢。
【问题讨论】:
-
嘿,不打算作为答案发布,因为这是 Android 上的第 2 天(目前是 iOS),但是......看起来你的 xml_background 定义的半径只有 3dp (而不是说......身高的一半)和一个灰色的笔画(CCC)。我会说你根本不想要那个中风。只是我的想法,-e
标签: android xml checkbox drawable