2011-09-09 6 views
0

можно использовать RelativeLayout, чтобы иметь одну область сверху, которая использует все доступное пространство (которое должно быть заполнено некоторыми видами динамически) и кнопкам, которые должны находиться в нижней части экрана?android RelativeLayout

Я попытался следующие, но без каких-либо усилий:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout android:id="@+id/relativeLayout1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

<FrameLayout 
    android:id="@+id/topFrame" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_margin="6dp"> 

    <TextView 
     android:text="blabla" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" /> 

</FrameLayout> 

<Button android:id="@+id/button1" 
    android:text="Button 1" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:layout_below="@id/topFrame" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_margin="6dp" /> 

<Button android:id="@+id/button2" 
    android:text="Button 2" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:layout_below="@id/button1" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 
    android:layout_margin="6dp" /> 

ти этого решения кнопка заполняет пространство, а не FrameLayout.

ответ

0

TRY это:

<RelativeLayout......> 
<FrameLayout 
android:id="@+id/topFrame" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_alignParentTop="true" 
android:layout_alignParentLeft="true" 
android:layout_alignParentRight="true" 
android:layout_margin="6dp"> 

<TextView 
    android:text="blabla" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 

</FrameLayout> 
<RelativeLayout 
    android:id="@+id/InnerRelativeLayout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" > 

    <Button 
     ..... 
    </Button> 

    <Button 
     ..... 
    </Button> 

</RelativeLayout> 
</RelativeLayout> 
0

В FrameLayout, изменить android:layout_height="wrap_content" к android:layout_height="fill_parent" затем включить android:layout_above="@+id/button1". Он должен заставить силу FrameLayout заполнить пространство и всегда находиться над первой кнопкой.

0

Попробуйте это.

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


<Button android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/button1" 
android:text="Button" 
android:layout_alignParentBottom="true" 
android:layout_alignParentRight="true" 
android:layout_alignParentLeft="true"/> 

<Button android:layout_height="wrap_content" 
android:id="@+id/button2" 
android:text="Button" 
android:layout_above="@+id/button1" 
android:layout_width="fill_parent" 
android:layout_alignParentLeft="true"/> 

<FrameLayout android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/frameLayout1" 
android:layout_above="@+id/button2" 
android:layout_alignParentTop="true" 
android:layout_alignParentRight="true" 
android:layout_alignParentLeft="true"> 

<TextView android:layout_height="wrap_content" 
android:text="TextView"   
android:layout_width="fill_parent" 
android:id="@+id/textView1"> 
</TextView> 


</FrameLayout> 

</RelativeLayout> 

Извините, если я что-то пропустил.

Смежные вопросы