【发布时间】:2019-02-26 22:31:26
【问题描述】:
我希望我的单选按钮具有与屏幕匹配的宽度,并且其文本与屏幕左侧对齐,按钮与右侧对齐。目前我的布局如下所示:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RadioGroup
android:id="@+id/optionsContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/sortingOptionRadioButton"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:layoutDirection="rtl"
android:text="Popularity"
android:layout_margin="@dimen/e2_space_small"
/>
</RadioGroup>
</LinearLayout>
在预览中它看起来就像我想要的那样,但是当我在我的设备上启动应用程序时,文本和按钮都与右侧对齐。 如何让文本和按钮对齐到对边?
【问题讨论】:
-
似乎
android:layoutDirection="rtl"导致了这种行为,请尝试删除此行。
标签: android android-layout android-radiobutton