这个LinearLayout应该使用android:layout_height ="wrap_content"?

Rob*_*met 9 android

我有以下xml布局:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true" >

  <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" // ==> here I get the error.
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Test"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="5dp"  />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="2dip"
        android:background="#298EB5"
        android:orientation="horizontal" />


  </LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

但是我收到了lint消息:

这个LinearLayout应该使用android:layout_height ="wrap_content"

为什么我收到此消息?

jnt*_*jns 10

LinearLayout设计用于堆叠元件并排或彼此叠加.我的猜测是,这个棉绒警告建议由于这个有利于堆叠ScrollView

文件:

"一个LinearLayout中的所有孩子都堆叠一个接一个,所以一个垂直列表将只有一个孩子每行,不管他们是多么宽,水平列表将会只有一个行高(最高孩子的身高,一个LinearLayout尊重孩子之间的边距和每个孩子的重力(右,中或左对齐)."