ConstraintLayout使用app:layout_constrainedHeight =“ true”隐藏TextView的最后一行

问题描述 投票:1回答:1

[我已经注意到ConstraintLayout(版本1.1.3)的怪异行为,每当我尝试通过TextView属性使用高度并将wrap_content设置为layout_constrainedHeight时,它都会隐藏true的最后一行。

使用layout_constrainedHeight

First image

没有layout_constrainedHeight

Second image

源代码:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:text="Lorem..."
        app:layout_constrainedHeight="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

我以为,每当我想将wrap_contentConstraintLayout结合使用时,都必须将layout_constrainedHeight设置为true,但这有时会给我带来怪异的错误。我想念什么吗?

编辑

如果我删除TextView周围的空白,效果很好。似乎ConstraintLayoutwrap_content和边距有误。

android android-constraintlayout android-jetpack
1个回答
0
投票
WRAP_CONTENT:强制执行约束(在1.1中添加)
© www.soinside.com 2019 - 2024. All rights reserved.