2013-03-30 5 views
7

私は日食にAndroidの糸くずを実行し、エラーを取得しています:このAndroid Lintの意味:「間違った向きですか?」

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

そして、これはエラーコードです:

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

それが何を意味するのでしょうか?このlintエラーを無視するとどうなりますか?

+0

レイアウトをテストすると考えられますか? – WarrenFaith

答えて

16

Android Lintは、Androidプロジェクトソースから潜在的なバグをスキャンするADT 16(およびツール16)で導入された新しいツールです。

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

レイアウトの方向を指定する必要があります。

<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。 lintによって実行されたチェックのリスト。

+0

オリエンテーションは何をしますか?私は「垂直」と「水平」との違いは見当たりません...? –

+0

linearlayoutに関するドキュメントを読む – Raghunandan

1

あなたは彼らがお互いの下にレンダリングする場合は互いに

android:orientation="horizontal" 

を想定するの横に2 ImageViewsとのTextViewがレンダリングされるのLinearLayoutに方向を指定しなかった場合使用する

android:orientation="vertical" 
関連する問題