Android的布局创建问题 [英] android layout creation issue

查看:131
本文介绍了Android的布局创建问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是新的Andr​​oid开发。我创建了一个Android应用程序,并为下面是我的main.xml

Am new to android development. I had created one android app and for that following is my 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>

我收到以下警告:

Am getting the following warning :

This LinearLayout layout or its RelativeLayout parent is possibly useless;
transfer the background attribute to the other view

谁能告诉此警告的原因和解决的问题。?

Can anyone tell the reason for this warning and a solution to the issue.?

推荐答案

有没有真正的使用情况,以刚内RelativeLayout的一个LinearLayout中。所以其中之一是无用的,这是多余的。

There is no real usage to have just a LinearLayout inside a RelativeLayout. So one of them is useless as this is redundant.

修改

这将触发警告,当一个布局只有一个孩子,也是一个布局。在这种情况下,这两个中的一个可没有任何问题被移除。它建议,因为它们降低了用户界面的整体性能,除去这些多余的布局。

This warning is triggered, when a Layout has only one child that is also a Layout. In this case one of both can be removed without any problems. It is recommended to remove these redundant layouts as they reduce the overall performance of the UI.

这篇关于Android的布局创建问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆