LinearLayout 或它的 LinearLayout 父级没用,我可以忽略警告消息吗?

Kin*_*gWu 5 layout android android-layout android-linearlayout android-lint

我面临嵌套布局问题并抛出一些异常。错误是“此 LinearLayout 布局或其 LinearLayout 父级无用......”。我知道我可以通过此设置忽略此警告。

设置:Build Path->Configure Build Path.... 在 Android Lint Preferences 下查找 UselessParent 并将其严重性设置为忽略或单击 Ignore All。

但是,Eclipse 图形布局无法显示任何内容并显示错误消息 - “索引:0,大小 0,异常详细信息记录在窗口 > 显示视图 > 错误日志中”。

如何使图形布局显示嵌套布局?

这是我的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@drawable/menu_bg2"
        android:orientation="vertical" >

        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/menu_item1"
            android:src="@drawable/alarm2x" />

        <ImageButton
            android:id="@+id/imageButton2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/menu_item2"
            android:src="@drawable/bank2x" />

        <ImageButton
            android:id="@+id/imageButton3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/menu_item3"
            android:src="@drawable/brief_case2x" />

        <ImageButton
            android:id="@+id/imageButton4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/menu_item4"
            android:src="@drawable/trolley2x" />

        <ImageButton
            android:id="@+id/imageButton5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/menu_item5"
            android:src="@drawable/calculator2x" />

    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

谢谢大家。

Adi*_*mro 2

你有两个LinearLayout,其中一个到现在都没用。此警告建议您删除其中一个。像这样:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/LinearLayout1"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@drawable/menu_bg2"
          android:orientation="vertical" >

     <!-- your other ImageView etc.-->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)