Android 此RelativeLayout布局或其LinearLayout父级可能没有用处?

Android 此RelativeLayout布局或其LinearLayout父级可能没有用处?,android,android-layout,Android,Android Layout,我有以下xml在RelativeLayout中得到的: 警告: This RelativeLayout layout or its LinearLayout parent is possibly useless XML文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/heading" xmlns:android="http://schemas.android.c

我有以下
xml
RelativeLayout
中得到的:

警告:

This RelativeLayout layout or its LinearLayout parent is possibly useless
XML文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    android:id="@+id/heading"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <RelativeLayout <--- This RelativeLayout layout or its LinearLayout parent is possibly useless -->
        android:id="@+id/dings"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_margin="8dip">

        <ProgressBar
            android:id="@+id/prgDownload"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="fill_parent"
            android:layout_height="32dip"/>

        <TextView
            android:id="@+id/txtDownload"
            android:layout_width="fill_parent"
            android:layout_height="32dip"
            android:gravity="center"
            android:text="..."
            android:textColor="#afafaf"
            android:textSize="18dip"
            android:textStyle="bold" />
    </RelativeLayout>

</LinearLayout>


注意:我的
LinearLayout
垂直的
,但当我使用它时,它会在
图形布局中转换为
水平的

线性布局包含一个相对布局,其中包含其余视图。只要删除线性布局标签,您就可以开始了

这意味着您正在将RelativeLayout包装在LinearLayout中,但实际上需要相对布局,您只需删除LinearLayout即可

正如上面所说的。LinearLayout是冗余的,因为它包含的只是一个RelativeLayout。只是删除它。你的确切问题是什么?我们无法理解它,并且IDE已经建议你它的父布局是无用的,这意味着你需要删除该线性布局只需保留相对布局并使其子布局为父布局删除线性布局作为父布局但我需要线性布局。你需要它做什么?该警告之所以存在,是因为,正如您的代码当前所示,LinearLayout没有达到RelativeLayout尚未达到的目的。如果你计划以后需要它,那么就忽略这个警告。有时候我在一个框架内有线性布局时会得到这个警告,因为我想要一个不同的框架背景颜色,并在内部布局周围使用填充来实现这一点。我已经检查了一遍又一遍,在我的具体案例中,警告是错误的。但是,我想不出任何理由将框架作为线性布局的唯一成员-您正在线性排列1个项目。如果您需要线性布局,请删除
RelativeLayout
tags@Jefferson您不理解这一点:)您有一个循环的事实(我假设您在代码中膨胀这个视图?),与是否需要线性布局无关。试试看!“需要相对布局”是什么意思?