Android RadioButton в TableLayout с гравитацией не отображается - PullRequest
0 голосов
/ 01 мая 2011

У меня есть этот макет:

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

радиокнопка с идентификатором radioButton1 не отображается. Если я удаляю его цвет фона, то он показывает. Если я сохраню цвет фона и удалим layout_gravity, который он показывает.

Кто-нибудь знает, что я сделал не так?

1 Ответ

1 голос
/ 01 мая 2011
Фон

RadioButton по умолчанию представляет собой 9-патч, который оставляет место для изображения переключателя рядом с меткой, так что это, вероятно, все портит. Если вы хотите установить цвет фона, я думаю, вам придется изменить исходное изображение 9patch (см. здесь ).

...