【发布时间】:2014-06-03 11:39:02
【问题描述】:
不确定我做错了什么,LinearLayout 中没有复杂的 2 个按钮,我得到了
“这个 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/GCBS_Template_BKGND"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/Partfinder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Part Finder" />
<Button
android:id="@+id/Heaterfinder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Heater Finder" />
</LinearLayout>
【问题讨论】:
-
在该问题中接受的答案只是隐藏了警告。我并不是说您不能忽略警告,但您得到警告是有原因的。您的相对布局仅包含另一个布局。警告意味着其中一个没有用,您可以删除其中一个。