【发布时间】:2015-05-27 01:43:38
【问题描述】:
如何将复选框更改为具有白色边框?我将复选框添加到深色背景中,如您所见,它几乎不可见。
【问题讨论】:
如何将复选框更改为具有白色边框?我将复选框添加到深色背景中,如您所见,它几乎不可见。
【问题讨论】:
您需要为选中状态和非选中状态创建 2 个不同的可绘制对象。例子-
<?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/white_color_box_with_tick" />
<item android:state_checked="false" android:drawable="@drawable/white_color_box_without_tick" />
</selector>
并按以下方式设置此可绘制对象-
<CheckBox
android:text="Custom CheckBox"
android:button="@drawable/checkbox_selector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
【讨论】: