我正在尝试为 ListView 创建一个布局,右侧有一个复选框,左侧有一些文本。复选框应一直对齐到右侧,TextView 应一直对齐到行的左侧,例如:
------------------------
text checkbox
------------------------
text checkbox
------------------------
text checkbox
------------------------
这是我目前所拥有的:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="8dip"
android:paddingBottom="8dip"
>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
/>
<CheckBox
android:id="@+id/chekcbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
/>
</RelativeLayout>
但是,实际呈现的是 TextBox 将复选框覆盖在行的左侧。
最佳答案
并在复选框属性中将复选框的框移到右侧
android:button="@null"
android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
关于android - 左对齐文本,右对齐复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7989014/