2013-03-30 8 views
7

Ich bin mit Android Flusen in Eclipse und eine Fehlermeldung erhalten:Was bedeutet dieser Android Lint Mean: "Falsche Ausrichtung?"

Wrong orientation? No orientation specified, and the default is horizontal, yet this layout has multiple children where at least one has layout_width="match_parent"

Issue: Checks that LinearLayouts with multiple children set the orientation Id: Orientation

Und dies ist der Fehlercode:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="@dimen/cell_height_1_of_3" > 

    <ImageView 
     android:id="@+id/item_cover" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_gravity="left" 
     android:layout_marginLeft="8dp" 
     android:scaleType="fitCenter" 
     android:src="@drawable/doc_item_icon" /> 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="@dimen/cell_height_1_of_3" 
     android:background="#0000" 
     android:padding="5dp" 
     android:scaleType="centerInside" 
     android:visibility="gone" /> 

    <TextView 
     android:id="@+id/item_title" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:ellipsize="end" 
     android:gravity="center" 
     android:maxLines="1" 
     android:text="Add new" 
     android:textColor="@color/office_color" 
     android:textSize="@dimen/textview_small_size" /> 

</LinearLayout> 

Was ist das? Was passiert, wenn ich diesen Flusenfehler ignoriere?

+0

Sie möchten Ihr Layout testen? – WarrenFaith

Antwort

16

Android Lint ein neues Werkzeug in ADT 16 (und Werkzeuge 16), die Android-Projekt Quellen durchsucht für potenzielle Fehler eingeführt ist.

http://developer.android.com/tools/help/lint.html.

Sie müssen die Ausrichtung für Ihr Layout angeben.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:orientation="vertical" //specify vertical or horizontal depending on your need 
    android:layout_height="@dimen/cell_height_1_of_3" > 

http://tools.android.com/tips/lint-checks. Liste der von lint durchgeführten Prüfungen.

+0

Was macht die Ausrichtung? Ich sehe keinen Unterschied von "vertikal" und "horizontal" ...? –

+0

Lesen Sie die Dokumentation zu linearlayout – Raghunandan

1

Wenn Sie nicht die Orientierung im Linearlayout geben Sie die 2 ImageViews und die Textview wird nebeneinander

android:orientation="horizontal" 

wird

angenommen werden

gemacht werden, wenn Sie wollen, untereinander zu erbringenden verwenden dann

android:orientation="vertical"