tags:

views:

106

answers:

2

Hi all

I have a linear layout with this form

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<RadioGroup android:id="@+id/group"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<RadioButton android:id="@+id/item1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item1"
android:checked="true" />
<RadioButton android:id="@+id/item2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item2" />


<RadioButton android:id="@+id/item3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item3" />
</RadioGroup>

 <TextView
    android:id="@+id/txt"
    android:layout_width="fill_parent"
android:layout_height="fill_parent"
    />
</LinearLayout>

this works fine but if I put the TextView above the RadioGroup like this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<TextView
    android:id="@+id/txt"
    android:layout_width="fill_parent"
android:layout_height="fill_parent"
    />
   <RadioGroup
   android:id="@+id/group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

>
<RadioButton android:id="@+id/item1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item1"
android:checked="true"
 />
<RadioButton android:id="@+id/item2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item2" />
<RadioButton android:id="@+id/item3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item3" />
</RadioGroup>
</LinearLayout>

the activity appears blank

what can be the reason for this

thanks

+2  A: 

Your TextView's layout_height is set to fill_parent, so it's....filling it's parent, leaving no space for the RadioGroup. Change it to wrap_content.

Rich
A: 

Probably because you have `layout_width="fill_parent"' set on your TextView, so if it happens first it will grab all the available space for itself, leaving none for the RadioGroup.

David