eclipse提示:
This RelativeLayout layout or its LinearLayout parent is possibly
useless; transfer the background attribute to the other view
但实测都有用,怎么处理这个提示?
奉上代码:
- XML code
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/widget52"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"android:background="@drawable/beijing_heng" ><!-- 横向 --><RelativeLayoutandroid:id="@+id/widget54"android:layout_width="fill_parent"android:layout_height="fill_parent"><ImageViewandroid:id="@+id/widget01"android:layout_width="fill_parent"android:layout_height="wrap_content"android:src="@drawable/ling_dang"android:contentDescription="@string/hello"android:paddingTop="10dip"></ImageView><ImageViewandroid:id="@+id/widget02"android:layout_width="fill_parent"android:layout_height="wrap_content"android:src="@drawable/plm"android:contentDescription="@string/hello"android:paddingTop="80dip"></ImageView><ImageViewandroid:id="@+id/widget03"android:layout_width="fill_parent"android:layout_height="wrap_content"android:src="@drawable/jiantou_you"android:contentDescription="@string/hello"android:paddingTop="150dip"></ImageView></RelativeLayout></LinearLayout>
这个代码实测都有用的。
------解决方案--------------------
这个叹号不影响吧,只要不是红色的就行!黄色的感叹号,忽视!
------解决方案--------------------
楼主有轻微强迫症啊,哈哈,警告都不想看到
------解决方案--------------------
这些提示告诉你RelativeLayout 外面有一个 LinearLayout,这个 LinearLayout是无效的,你可以去掉这个 LinearLayout,如果不去掉的等方面 RelativeLayout 北京是透明的,北京用LinearLayout背景颜色。
------解决方案--------------------
你build project一下就OK了
------解决方案--------------------
我也是告0容忍,哈哈
------解决方案--------------------
------解决方案--------------------
8楼正解 你在viewgroup里面仅仅套了一个viewgroup 那eclipse就会觉得你最外面的是没用的
就像你把一个篮子放到另一个篮子里面 再装东西 那最外那那个 不是没有用么
------解决方案--------------------
楼上有道理,把android:background="@drawable/beijing_heng" 放在RelativeLayout中,把LinearLayout干掉
------解决方案--------------------
干吗要LinearLayout就嵌一个RelativeLayout呢。外面的linearLayout岂不没啥用,直接去掉外面的LinearLayout,直接用RelativeLayout不久行了,兄弟不要浪费资源啊 哈哈