2014-03-27 176 views
0

我有線性佈局此LinearLayout佈局或其RelativeLayout父項是無用的;垂直和水平方向

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#1875b5" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".AboutUs" 
    tools:ignore="HardcodedText" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="25dp" 
      android:layout_marginTop="15dp" 
      android:background="#186db5" 
      android:orientation="horizontal" > 

這裏你可以看到所有的代碼 http://www.a2b4.net/linearlayout.txt
不要有

This LinearLayout layout or its RelativeLayout parent is useless; transfer the background attribute to the other view警告。

我如何合併,不會有警告。

一個是水平的其他垂直。

+2

目前還不清楚你在問什麼。你是否收到一條警告信息,表示你的某個佈局是無用的?另外,請提供您的整個佈局文件,以便我們可以看到這些部件是如何相關的。 – scottt

+0

這裏是所有的代碼http://www.a2b4.net/linearlayout.txt – lospicos

+0

哇,這是很多佈局!爲了提高性能並避免內存問題,對RelativeLayout(s),GridView或TableLayout的left-of/right-of等屬性可能會更好。但我會檢查你現有的方法... – scottt

回答

0

刪除您的外部LinearLayout;它不會增加您的佈局。您可以直接刪除第一套這些行:

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

和最後一行:

</LinearLayout> 

然後,添加一個ID,(新的第一)的LinearLayout定義似乎是你的前往路線:

android:id="@+id/heading" 

最後一個定位屬性來滾動視圖:

android:layout_below="@+id/heading" 
+0

當我這樣做,我得到了這個結果http://i.imgur.com/cSIP96F.png – lospicos

+0

我的佈局就像這樣http://i.imgur.com/hEpwmq1.png – lospicos

+0

如果你有任何suggetsion – lospicos

相關問題