【问题标题】:why does the `android:layout_height="0dp" ` produce the same result as `android:layout_height="wrap_content" ` in XML为什么`android:layout_height="0dp"`在XML中产生与`android:layout_height="wrap_content"`相同的结果
【发布时间】:2018-06-05 17:27:34
【问题描述】:

XML 代码----

 <TextView
            android:text="DOGS"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:textSize="24sp" />

XML 代码----

<TextView
                android:text="DOGS"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="24sp" />

当 layout_height 设置为 0dp 时,当 layout_height 设置为 wrap_content 时会产生令人自豪的结果,并且宽度也相同。如果两者都产生相同的结果,那么为什么需要另一个。

【问题讨论】:

标签: android xml android-linearlayout


【解决方案1】:

因为 android:textSize="24sp" 设置你的文本视图的高度。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-27
    • 1970-01-01
    • 2013-08-08
    • 2017-11-27
    • 1970-01-01
    • 2021-09-09
    • 2014-10-18
    相关资源
    最近更新 更多