2011-09-09 9 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

시도이 다음에 FrameLayout이

<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

다음 android:layout_above="@+id/button1"android:layout_height="fill_parent"android:layout_height="wrap_content"을 포함하도록 변경. 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> 

내가 뭔가를 놓친 경우 죄송합니다.

관련 문제