我需要對齊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中具有相對的Android佈局內的單選按鈕
- 2. 如何取消選中Android中的單選按鈕(在radiogroup中)?
- 3. 的Android RadioGroup中,單選按鈕,按鈕同一行
- 4. 使用Android中的圖像製作RadioGroup單選按鈕...如何?
- 5. 單選按鈕對齊
- 6. 嘗試在複合佈局中對齊RadioGroup中的單選按鈕
- 7. Android的單選按鈕
- 8. Ext RadioGroup - 如何訪問所選單選按鈕的值?
- 9. Android按鈕對齊
- 10. Android的單選按鈕
- 11. 在同一個radiogroup中水平和垂直對齊單選按鈕
- 12. radioGroup如何隱藏按鈕android
- 13. 如何在中心對齊時使單選按鈕齊平?
- 14. 使用RadioGroup中和單選按鈕
- 15. 機器人 - 單選按鈕和RadioGroup中
- 16. (Robotium)如何在RadioGroup中選擇一個單選按鈕
- 17. 如何設置單選按鈕選中爲默認RadioGroup中與Android
- 18. 如何在Android中對齊按鈕
- 19. 如何將動態創建的單選按鈕設置爲RadioGroup?
- 20. Android單選按鈕圖像
- 21. 將單選按鈕對齊到中心
- 22. Jquery dform插件單選按鈕對齊
- 23. IE單選按鈕對齊問題
- 24. 單選按鈕未正確對齊
- 25. HTML - 對齊單選按鈕和文本
- 26. 單選按鈕對齊樣式屬性
- 27. 無法對齊單選按鈕列表
- 28. 通過checkradio對齊單選按鈕
- 29. 單選按鈕頂部對齊子彈
- 30. 單選按鈕Android
無法正常工作。對齊是好的。但它不會表現爲一個無線電組。我可以選擇多個按鈕。 –