当我正在开发一个应用程序时,我需要单选按钮,我决定创建一个RadioGroup
,并在其中创建了3个RadioButton
,并希望将它们相应地定位到左侧、中间和右侧。
我将android:orientation:"horizontal"
放在RadioGroup
中,并将android:layout_gravity="left
放置在RadioButton
的右边或中间,在RadioGroup中创建,但它只是将按钮放置在彼此对齐的左边,并稍微扭曲了文本。
如果我将android:gravity="left"
应用于按钮,也会发生同样的情况。
我不知道如何对齐左边的第一个按钮,中间的第二个按钮,右边的第三个按钮。
谢谢!
发布于 2014-11-16 11:26:45
在你的布局中试试这个:
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="horizontal">
<RadioButton
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="1"/>
<RadioButton
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="2"/>
<RadioButton
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="3"/>
</RadioGroup>
https://stackoverflow.com/questions/26961036
复制相似问题