Android RadioButton in TableLayout with gravity not showing
I have this layout:
<?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开发者_JAVA百科="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>
the radiobutton with the ID radioButton1 is not displayed. If i remove its background color then it shows. If i keep the background color and remove the layout_gravity it shows.
Does anybody know what I did wrong?
RadioButton
's background by default is a 9patch that leaves the space for the radio button image next to the label, so that's probably messing everything up. If you want to set a background color I think you'll have to modify the original 9patch image (see here).
精彩评论