gpt4 book ai didi

android - 使用 0dip 的 layout_height 而不是 wrap_content 以获得更好的性能......如何删除此警告

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

如何去除这个警告?

使用 0dip 的 layout_height 而不是 wrap_content 以获得更好的性能

最佳答案

好吧,让我通过一个例子来解释,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Hello World!!" />

</LinearLayout>

在上面的示例中,我为 TextView 使用了 android:layout_weight="1",通过它我告诉布局我的 TextView 将采用父布局 (LinearLayout) 的全高。因此,在这种情况下,android:layout_height="wrap_content" 没有用,因为 TextView 将具有父级 LinearLayout 的完整尺寸。因此,在这种情况下,最好添加 android:layout_height="0dp" 以使 TextView 将自身包裹到父 Layout 的高度。

关于android - 使用 0dip 的 layout_height 而不是 wrap_content 以获得更好的性能......如何删除此警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11304655/

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