[英]Android RadioButton in TableLayout with gravity not showing
我有這個布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*" android:background="#00ff00">
<TableRow android:layout_margin="1dip">
<TextView android:text="col 1" android:background="#0000ff" android:layout_margin="1dip"/>
<TextView android:text="col 2" android:background="#0000ff" android:layout_margin="1dip"/>
<TextView android:text="col 3" android:background="#0000ff" android:layout_margin="1dip"/>
<TextView android:text="col 4 with more text" android:background="#0000ff" android:layout_margin="1dip"/>
</TableRow>
<TableRow android:layout_margin="1dip" >
<TextView android:layout_height="fill_parent" android:text="text" android:background="#0000ff" android:layout_margin="1dip"/>
<TextView android:layout_height="fill_parent" android:text="text" android:background="#0000ff" android:layout_margin="1dip"/>
<RadioButton android:background="#0000ff" android:id="@+id/radioButton1" android:layout_gravity="center" ></RadioButton>
<RadioButton android:id="@+id/radioButton2" android:layout_gravity="center" >
</RadioButton>
</TableRow>
</TableLayout>
</ScrollView>
不顯示 ID 為 radioButton1 的單選按鈕。 如果我刪除它的背景顏色然后它顯示。 如果我保留背景顏色並刪除它顯示的 layout_gravity。
有人知道我做錯了什么嗎?
RadioButton
的默認背景是 9patch,它為 label 旁邊的單選按鈕圖像留出了空間,所以這可能會搞砸一切。 如果您想設置背景顏色,我認為您必須修改原始的 9patch 圖像(請參閱此處)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.