我需要对齐RadioGroup中的RadioButton,就像RelativeLayout一样。我读过RadioGroup是从LinearLayout继承的,可能我不能像内部的RelativeLayout那样对齐内容。我试图实现的实际内容是RadioGroup中的两行,第一行包含两个RadioButton,在第二行中,我必须在其开始处添加另一个按钮。我怎么能这样做?我如何对齐radiogroup android内的单选按钮?
0
A
回答
0
你可以尝试这种布局,让我知道,如果这对你有用。如果需要,我可以修改。
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Red"/>
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Blue"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioButton
android:id="@+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Green"/>
</LinearLayout>
</RadioGroup>
</LinearLayout>
1
所有你需要做的是设置在无线电集团定向横向到它们对齐水平看看下面的代码。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin">
<RadioGroup
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="match_parent">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New RadioButton"
android:id="@+id/radioButton" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New RadioButton"
android:id="@+id/radioButton2" />
</RadioGroup>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New RadioButton"
android:layout_gravity="start"
android:id="@+id/radioButton3" />
</LinearLayout>
相关问题
- 1. RadioGroup /按钮对齐
- 2. RadioGroup中具有相对的Android布局内的单选按钮
- 3. 的Android RadioGroup中,单选按钮
- 4. 对齐div内的单选按钮
- 5. 对齐radioGroup中的按钮horzintally
- 6. 如何取消选中Android中的单选按钮(在radiogroup中)?
- 7. 如何水平对齐单选按钮
- 8. 如何垂直对齐单选按钮
- 9. 的Android RadioGroup中,单选按钮,按钮同一行
- 10. 单选按钮对齐
- 11. 使用Android中的图像制作RadioGroup单选按钮...如何?
- 12. 如何正确对齐android studio中的单选按钮?
- 13. 如何在相对的Android布局中为单选按钮进行Radiogroup
- 14. 如何在radioGroup中对齐radioButton和textView?
- 15. 尝试在复合布局中对齐RadioGroup中的单选按钮
- 16. Android单选按钮选择
- 17. 单选按钮android
- 18. RadioGroup在Android中对齐
- 19. Ext RadioGroup - 如何访问所选单选按钮的值?
- 20. 如何在XMLUI radiogroup中设置选定的单选按钮?
- 21. Android的单选按钮
- 22. Android按钮对齐
- 23. Android的单选按钮
- 24. 如何在中心对齐时使单选按钮齐平?
- 25. 与单选按钮的面板对齐
- 26. 在同一个radiogroup中水平和垂直对齐单选按钮
- 27. android-单选按钮
- 28. radioGroup如何隐藏按钮android
- 29. 机器人 - 单选按钮和RadioGroup中
- 30. 使用RadioGroup中和单选按钮
无法正常工作。对齐是好的。但它不会表现为一个无线电组。我可以选择多个按钮。 –