此LinearLayout布局或其LinearLayout父级是无用的

时间:2014-01-11 18:09:51

标签: android eclipse

我收到以下警告:

  

此LinearLayout布局或其LinearLayout父级无用;   将background属性传递给另一个视图。

无法弄清楚是什么问题。阅读其他论坛,但他们没有帮助。有任何想法吗?

以下是代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="@drawable/background"
android:orientation="vertical" >

 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:gravity="bottom"
    android:orientation="vertical" >


<Button
    android:id="@+id/button1"
    android:layout_width="145dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textStyle="bold"
    android:hint="@string/Play_Button" />

<Button
    android:id="@+id/button2"
    android:layout_width="145dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textStyle="bold"
    android:hint="@string/Progress_Button" />

<Button
    android:id="@+id/button3"
    android:layout_width="145dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textStyle="bold"
    android:hint="@string/About_Button" />
</LinearLayout>

</LinearLayout>

1 个答案:

答案 0 :(得分:1)

您没有使用外部线性布局,因此您可以像这样放置UI:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="@drawable/background"
android:orientation="vertical" >

<Button
    android:id="@+id/button1"
    android:layout_width="145dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textStyle="bold"
    android:hint="@string/Play_Button" />

<Button
    android:id="@+id/button2"
    android:layout_width="145dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textStyle="bold"
    android:hint="@string/Progress_Button" />

<Button
    android:id="@+id/button3"
    android:layout_width="145dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:textStyle="bold"
    android:hint="@string/About_Button" />

</LinearLayout>
相关问题