这个RelativeLayout布局或者它的LinearLayout父是没用的 [英] This RelativeLayout layout or its LinearLayout parent is useless

查看:48
本文介绍了这个RelativeLayout布局或者它的LinearLayout父是没用的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Android 3.1.及以上应用.

I'm developing an Android 3.1. and above application.

在一个活动中,我动态生成其布局.我使用 formdetail.xml 作为内容视图:

On one activity I generate its layout dynamically. I'm using formdetail.xml as contentview:

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.formdetail);

    Bundle extras = getIntent().getExtras();
    if (extras != null)
    {
        currentFormId = extras.getString("FormId");
    }
}

formdetail.xml :

formdetail.xml :

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

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
        <Button
            android:id="@+id/downloadFormsButton"
            android:enabled="false"
            android:layout_alignParentLeft="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:text="@string/download_forms_button" />
        <TextView
            android:id="@+id/formErrorMsg"
            android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:textSize="16dp" >
        </TextView>
    </RelativeLayout>

</LinearLayout>

downloadFormsButtonformErrorMsg 必须始终在表单中.

downloadFormsButton and formErrorMsg must be always in form.

但是使用那个 xml 我得到这个警告:

But using that xml I get this warning:

这个RelativeLayout布局或者它的LinearLayout父级是没用的

我需要 linearLayout 以编程方式添加 TableLayouts.

I need linearLayout to add TableLayouts programmatically.

我该如何解决这个警告?

How can I solve this warning?

推荐答案

您可以忽略它或右键单击您的项目.点击Build Path->Configure Build Path....在 Android Lint Preferences 下查找 UselessParent 并将其严重性设置为忽略或单击 Ignore All.

You either ignore it or right click your project. Click Build Path->Configure Build Path.... Under Android Lint Preferences look for UselessParent and set it's severity to ignore or click Ignore All.

我收回最后一部分.我认为 Ignore All 将清除所有 Lint 警告和错误.

I take that last part back. I think Ignore All will wipe all Lint warnings and errors.

这篇关于这个RelativeLayout布局或者它的LinearLayout父是没用的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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