我正在尝试模仿手机上设置应用程序中的 CheckBox
它看起来像这样:

我试过使用单独的 TextView s,但这样只有复选标记是可点击的,而不是文本和复选标记。
有没有办法做到这一点?
我也尝试了 CheckedTextView 但找不到合适的可绘制对象。

最佳答案

据我所知这应该有效

<?xml version="1.0" encoding="utf-8"?>
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
    android:text="Text"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:button="@null"
    android:drawableRight="?android:attr/listChoiceIndicatorMultiple"/>

使用 android:button="@null" 删除标准复选框按钮/图像,然后将复选框图像添加为右可绘制(或使用 drawableEnd 支持 RTL)
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"

10-07 19:23
查看更多