Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this Android Lint Mean: "Wrong orientation?"

I'm running Android lint in eclipse and get a error:

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

And this is the error code:

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

What does it mean? What will happen if I ignored this lint error?

like image 904
herbertD Avatar asked Mar 30 '13 12:03

herbertD


2 Answers

Android Lint is a new tool introduced in ADT 16 (and Tools 16) which scans Android project sources for potential bugs.

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

You have to specify orientation for your layout.

  <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. list of the checks performed by lint.

like image 153
Raghunandan Avatar answered Nov 03 '22 11:11

Raghunandan


If you didn't specify orientation in the LinearLayout the 2 ImageViews and the TextView will be rendered beside each other

android:orientation="horizontal"

will be assumed

If you want them to be rendered below each other then use

android:orientation="vertical"
like image 26
Shehabic Avatar answered Nov 03 '22 10:11

Shehabic