Android 更改复选框的厚度
我正在使用自定义AppCompatCheckBox,但我需要更改该复选框的厚度和颜色边框,如下所示:Android 更改复选框的厚度,android,checkbox,Android,Checkbox,我正在使用自定义AppCompatCheckBox,但我需要更改该复选框的厚度和颜色边框,如下所示: 您只需设置相关的可绘制图形,并在复选框中进行设置: <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="new checkbox" android:background="@drawable/my_checkbo
您只需设置相关的可绘制图形,并在复选框中进行设置:
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="new checkbox"
android:background="@drawable/my_checkbox_background"
android:button="@drawable/my_checkbox" />
请使用显示复选框的代码制作一个可绘制的图形: draw\u chackbox.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item>
<shape android:shape="rectangle">
<padding android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp"/>
<corners android:radius="4dp"/>
<size android:height="24dp"
android:width="24dp"/>
<stroke android:color="@color/gray_default_font"
android:width="1dp"/>
</shape>
</item>
</layer-list>
</item>
</selector>
并在复选框属性中使用
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="new"
android:button="@drawable/draw_chackbox" />
将此添加到主布局中。希望能对您有所帮助。试试看,您想保持物质效果吗?如果没有,则单个选择器XMl将起作用。我希望保持材质效果。这将导致无法选中布局复选框。