但我收到了 lin-6ren">
gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:24:26 24 4
gpt4 key购买 nike

我有以下 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>

但我收到了 lint 消息:

This LinearLayout should use android:layout_height="wrap_content"

为什么我会收到这条消息?

最佳答案

LinearLayout 设计用于并排或堆叠元素。我的猜测是,由于 ScrollView

,此 lint 警告建议使用虚拟堆叠

Documentation :

“LinearLayout 的所有子项都一个接一个地堆叠,因此垂直列表每行只有一个子项,无论它们有多宽,而水平列表只有一个行高(最高子项的高度,加上填充)。LinearLayout 考虑子项之间的边距和每个子项的重力(右对齐、居中对齐或左对齐)。”

关于android - 这个 LinearLayout 应该使用 android :layout_height ="wrap_content"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12424352/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com