android布局创建问题

Tij*_*ese 4 java android android-layout

是Android开发的新手.我创建了一个Android应用程序,以下是我的main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:background="@drawable/bg"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@+id/grid_layout_1"
    android:layout_centerInParent="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >
    <Button android:id="@+id/btnLogin" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:text="@string/login_btn_text"/>
    <Button android:id="@+id/btnRegister" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:text="@string/reg_btn_text"/>

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

我收到以下警告:

This LinearLayout layout or its RelativeLayout parent is possibly useless;
transfer the background attribute to the other view
Run Code Online (Sandbox Code Playgroud)

任何人都可以说出这个警告的原因并解决问题.

War*_*ith 6

在RelativeLayout中只有一个LinearLayout没有实际用途.因此,其中一个是无用的,因为这是多余的.

编辑

当布局只有一个也是布局的子项时,会触发此警告.在这种情况下,可以毫无问题地移除其中一个.建议删除这些冗余布局,因为它们会降低UI的整体性能.