java - Android 复选框白色边框

标签 java android xml checkbox

如何将复选框更改为白色边框?我将复选框添加到深色背景中,如您所见,它几乎不可见。

enter image description here

最佳答案

您需要为选中状态和非选中状态创建 2 个不同的可绘制对象。示例-

checkbox_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/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"/> 

关于java - Android 复选框白色边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29220904/

相关文章:

java - Guava 。 CharStreams 检查 null

java - 我可以通过编程方式检测当前 WiFi 网络上是否有任何 Chromecast 设备吗?

android - 无法访问androidx.lifecycle.LifecycleOwner,Android中error是什么意思?

java - 使用 SOAP 使用 Web 服务

java - 调用 Fragment 的空构造函数而不是 newInstance

c# - Newtonsoft.Json JsonConvert to XmlDocument 元素有属性时日期格式不一致

c# - 使用 Web Api MVC 4 反序列化嵌套的 XML

java - 无法将设备连接到本地主机

android - 使用库项目和 android.view.InflateException 二进制 XML 文件行 #7 错误膨胀类

java - 当我尝试从文件中读取某些字节时,为什么索引会超出范围?