Android 中 CheckBox 右侧的文本

Dor*_*nar 4 checkbox android android-layout

我正在尝试模仿CheckBox手机上“设置”应用程序中的s。它看起来像这样: 我的 Galaxy S4 5.0.1 设置应用程序中的复选框

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

dme*_*vic 6

据我所知这应该有效

<?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"/>
Run Code Online (Sandbox Code Playgroud)

随着android:button="@null"您删除标准复选框按钮/图像,之后你只需要添加复选框形象权绘制(或使用drawableEnd支持RTL)

android:drawableRight="?android:attr/listChoiceIndicatorMultiple"


Rak*_*ani 3

尝试以下 Xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:weightSum="10"
    tools:context="com.example.pager.MainActivity" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:text="Anything you want here" />

    <CheckBox
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="8" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

效果很好