2011-05-01 72 views
0

我有這樣的佈局:的Android單選按鈕在TableLayout與重力沒有顯示

<?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。

有人知道我做錯了什麼嗎?

回答

1

RadioButton的默認背景是一個9patch,它爲標籤旁邊的單選按鈕圖像留下空間,所以這可能會讓所有的東西都搞亂。如果你想設置背景顏色,我認爲你必須修改原始9patch圖像(請參閱here)。