Das RelativeLayout layout oder den übergeordneten LinearLayout ist nutzlos

Ich bin die Entwicklung einer Android 3.1. und oben Anwendung.

Auf eine Tätigkeit, die ich generieren, deren layout sich dynamisch. Ich bin mit formdetail.xml als 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 :

<?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>

downloadFormsButton und formErrorMsg muss immer in form.

Aber mit diesem xml bekomme ich diese Warnung:

This RelativeLayout layout or its LinearLayout parent is useless

Brauche ich linearLayout hinzufügen TableLayouts programmgesteuert.

Wie kann ich das Problem lösen diese Warnung?

Ich denke, deine Eltern-layout wrap nur ein Kind, und das können Sie optimieren, Ihr layout durch das entfernen von übergeordneten LinearLayout

InformationsquelleAutor VansFannel | 2012-04-25

Schreibe einen Kommentar