这应该的LinearLayout采用Android:layout_height =" WRAP_CONTENT"? [英] This LinearLayout should use android:layout_height="wrap_content"?

查看:145
本文介绍了这应该的LinearLayout采用Android:layout_height =" WRAP_CONTENT"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的XML布局:

I have the following xml layout :

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

但我得到的皮棉消息:

But I get the lint message :

这LinearLayout中应采用Android:layout_height =WRAP_CONTENT

This LinearLayout should use android:layout_height="wrap_content"

为什么我得到这个消息?

Why do I get this message?

推荐答案

的LinearLayout 的被设计用于堆叠或者通过侧或在彼此的顶侧的元件。我的猜测是,这皮棉警告建议virtical堆叠由于滚动型

LinearLayout's are designed for stacking elements either side by side or on top of each other. My guess is that this lint warning recommends virtical stacking due to the ScrollView

文档

是一个LinearLayout中的所有子堆叠另一方面,这样一个垂直列表中只会有每行,一个孩子不管他们有多宽都和一个水平列表将会只有一个后行高(最高孩子的身高,再加上填充),一个LinearLayout中尊重孩子,每个孩子的比重(右,中置,或左对齐)之间的利润率。

"All children of a LinearLayout are stacked one after the other, so a vertical list will only have one child per row, no matter how wide they are, and a horizontal list will only be one row high (the height of the tallest child, plus padding). A LinearLayout respects margins between children and the gravity (right, center, or left alignment) of each child."

这篇关于这应该的LinearLayout采用Android:layout_height =&QUOT; WRAP_CONTENT&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆