0

我有Android佈局問題。我有(1)一個ScrollView(2)一個TableLayout(3)頁腳LinearLayout。 目前,如果TableRow太多,表格將重疊頁腳佈局。 以下是我的xml佈局。Android:兩個LinearLayout在ScrollView中重疊

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#F7F7F7"> 

    <LinearLayout 
     android:id="@+id/account_section" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

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

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <TableRow 
       android:layout_width="wrap_content" 
       android:layout_height="100dp" 
       android:background="#CCCCCC"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:text="1" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="wrap_content" 
       android:layout_height="100dp" 
       android:background="#CCCCCC"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:text="2" /> 
      </TableRow> 

      <TableRow 
       android:layout_width="wrap_content" 
       android:layout_height="100dp" 
       android:background="#CCCCCC"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:text="3" /> 
      </TableRow> 

     </TableLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/footer_section" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:orientation="vertical"> 

     <ImageView 
      android:id="@+id/footer_image" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/footer_image" /> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/footer_height" 
      android:background="#333333"> 

      <TextView 
       android:id="@+id/usage" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:text="Test" /> 

      <TextView 
       android:id="@+id/dashboard_copy_right" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:text="@string/copy_right" /> 

     </RelativeLayout> 
    </LinearLayout> 

</RelativeLayout> 
</ScrollView> 

如果TableRow太多,「表」將與「頁腳」重疊。 如何解決這個佈局問題?

在此先感謝。 埃裏克

添加截圖 enter image description here

+0

這可能是因爲你已經硬編碼了'機器人:layout_height = 「100dp」'。你不能把它設置爲'wrap_content'或'fill_parent'嗎? – 2015-02-12 07:33:06

+0

不,我測試過了,它不是硬編碼的100dp問題 – 2015-02-12 07:38:55

+0

您可以發佈顯示問題的屏幕截圖嗎? – 2015-02-12 07:40:12

回答

0

使用此佈局,看看它是否

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

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/footer_section" > 

     <LinearLayout 
      android:id="@+id/account_section" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

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

      <TableLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" > 

       <TableRow 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:background="#CCCCCC" > 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="100dp" 
         android:text="1" /> 
       </TableRow> 

       <TableRow 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:background="#CCCCCC" > 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="100dp" 
         android:text="1" /> 
       </TableRow> 

       <TableRow 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:background="#CCCCCC" > 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="100dp" 
         android:text="1" /> 
       </TableRow> 

       <TableRow 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:background="#CCCCCC" > 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="100dp" 
         android:text="1" /> 
       </TableRow> 

       <TableRow 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:background="#CCCCCC" > 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="100dp" 
         android:text="1" /> 
       </TableRow> 

       <TableRow 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:background="#CCCCCC" > 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="100dp" 
         android:text="1" /> 
       </TableRow> 

       <TableRow 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:background="#CCCCCC" > 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="100dp" 
         android:text="1" /> 
       </TableRow> 

       <TableRow 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:background="#CCCCCC" > 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="100dp" 
         android:text="2" /> 
       </TableRow> 

       <TableRow 
        android:layout_width="wrap_content" 
        android:layout_height="100dp" 
        android:background="#CCCCCC" > 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="100dp" 
         android:text="3" /> 
       </TableRow> 
      </TableLayout> 
     </LinearLayout> 
    </ScrollView> 

    <LinearLayout 
     android:id="@+id/footer_section" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:orientation="vertical" > 

     <ImageView 
      android:id="@+id/footer_image" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:src="@drawable/ic_launcher" /> 

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:background="#333333" > 

      <TextView 
       android:id="@+id/usage" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:text="Test" /> 

      <TextView 
       android:id="@+id/dashboard_copy_right" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:text="copy_right" /> 
     </RelativeLayout> 
    </LinearLayout> 

</RelativeLayout> 
+0

我在對齊佈局方面做了一些更改...希望它的好... – MRX 2015-02-12 08:08:11

+0

不起作用,頁腳文本「測試」和「複製權限」不會顯示。 – 2015-02-12 08:15:32

+0

不工作,如果TableRow不是很多,頁腳應該在屏幕的底部,而不是在表格下方 – 2015-02-12 08:17:17