如何将复选框与文本对齐到屏幕右侧?

Fra*_*ero 3 checkbox android

我有一个复选框TableRow.我想将复选框和文本对齐到屏幕的右侧,但是当我使用android:gravity="right"它时,只将文本对齐到屏幕的右侧而不是正方形(复选框本身).它们似乎是分开对齐的(左侧是复选框,屏幕右侧是文本).

以下是xml的片段,它引用了复选框:

<TableRow android:layout_height="wrap_content"
          android:layout_width="match_parent"
          android:layout_marginBottom="10dp">

          <CheckBox
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Select"
                android:id="@+id/checkboxSelect"
                android:layout_column="0"
                android:layout_weight="1"
                android:gravity="right"/>
</TableRow>
Run Code Online (Sandbox Code Playgroud)

如何将复选框和文本对齐到屏幕右侧?

提前致谢!

Jay*_* RJ 6

只需添加Checkbox如下.

<?xml version="1.0" encoding="utf-8"?>
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
    android:text="hello"
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:button="@null"
    android:drawableRight="?android:attr/listChoiceIndicatorMultiple"/>
Run Code Online (Sandbox Code Playgroud)

它会text在左侧和check box右侧显示.