2015-11-05 55 views
0

頁腳棍這是我的活動版面內容:如何使標題 - 內容 - 頁腳佈局的Android與底部

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

    <RelativeLayout 
     android:id="header" 
     android:layout_width="fill_parent" 
     android:layout_height="50"> 

     <TextView 
      android:layout_width="fill_parent " 
      android:layout_height="wrap_content" 
      android:text="Header" 
      android:textSize="40dp" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="main-content" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     > 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" android:text="Content" /> 

    </RelativeLayout> 

    <RelativeLayout 
     android:id="footer" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 

     > 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Footer" 
      android:textSize="40dp" /> 
    </RelativeLayout> 
</RelativeLayout> 

頁腳已經堅持到了谷底,但內容被貼到頂部而不是在「標題」之後。我想過使用「線性佈局」,但它沒有android:layout_alignParentBottom =「true」。我必須做什麼?

回答

0

只需將頁眉的佈局與父窗口對齊即可。 然後對齊標題下方的主要內容。

讓我編輯你,但我會讓你測試它..

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

    <RelativeLayout 
     android:id="header" 
     android:id="@+id/rl_header" 
     android:layout_width="fill_parent" 
     android:layout_height="50" 
     android:layout_alignParentTop="true"> 

     <TextView 
      android:layout_width="fill_parent " 
      android:layout_height="wrap_content" 
      android:text="Header" 
      android:textSize="40dp" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="main-content" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/rl_header"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Content" /> 

    </RelativeLayout> 

    <RelativeLayout 
     android:id="footer" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 

     > 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="Footer" 
      android:textSize="40dp" /> 
    </RelativeLayout> 
</RelativeLayout>