【发布时间】:2012-07-17 06:15:14
【问题描述】:
我遇到了嵌套布局问题并引发了一些异常。错误是“此 LinearLayout 布局或其 LinearLayout 父级无用......”。我知道我可以通过这个设置忽略这个警告。
设置: Build Path->Configure Build Path.... 在 Android Lint Preferences 下查找 UselessParent 并将其严重性设置为忽略或单击 Ignore All。
但是,Eclipse 图形布局无法显示任何内容并显示错误消息 - “Index:0, Size 0, Exception details are logged in Window > Show View > Error Log”。
如何让图形布局显示嵌套布局??
这是我的代码:
<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>
谢谢大家。
【问题讨论】:
-
Error Log显示什么错误? -
这里第二个布局有什么用......
-
在父布局中再添加一个视图(可能是空白的或一些可用的,如果有的话)以删除警告。在这段代码中,水平布局没有用。
-
Re Jin35:这是我的错误。 dl.dropbox.com/u/78582670/error.png Re RajaReddy:我想在线性布局中为 imageButton 播放一些翻译动画。我希望按钮从下到上移动。你有什么好主意吗? Re Kamal:水平布局很有用,因为我以后会在里面添加一些视图。
标签: android android-layout layout android-linearlayout android-lint