这个Android Lint意味着什么:“错误的方向?”

我在 eclipse中运行 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错误会怎么样?

解决方法

Android Lint是ADT 16(和工具16)中引入的一种新工具,可以扫描Android项目源以查找潜在的错误.

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执行的检查清单.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...