android - ConstraintLayout 用 app:layout_constrainedHeight="true" 隐藏 TextView 的最后一行
问题描述
我注意到ConstraintLayout
(版本 1.1.3)的奇怪行为,TextView
每当我尝试使用带wrap_content
属性的高度并layout_constrainedHeight
设置为true
.
与layout_constrainedHeight
:
没有layout_constrainedHeight
:
源代码:
<?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_content
with时,ConstraintLayout
我都必须设置layout_constrainedHeight
为 true,但这有时会给我带来奇怪的错误。我错过了什么吗?
编辑
如果我删除周围的边距TextView
,它可以正常工作。似乎这ConstraintLayout
在wrap_content
和边距方面有问题。
解决方案
推荐阅读
- c# - 更新到 Visual Studio 2017 15.8.6,现已完全损坏
- html - 一个字体真棒图标没有显示,尽管其他人这样做
- java - 根元素不应该重复,子节点只需要附加在 XML Dom Parser 中
- r - 如何检测从负值到正值的变化?
- amazon-web-services - 通过云形成堆栈为 ECS 发现 AWS 服务
- git - 切换分支而不更改本地忽略的文件
- oracle - 将 regexp_replace 连接到 listagg:结果太长(SQL 错误:ORA-01489)
- r - R中的舍入错误导致for循环中的错误结果
- c - 从指向结构中的指针的指针中读取值(SPI 事务)
- typescript - 我需要包括 admin.initializeApp(); 在我所有的 Firebase 云函数文件(Typescript)中?