为什么多行 Android TextView 的最后一行不显示?
Why does the last line of a multiline Android TextView not display?
我的问题: 我无法让最后一行出现在我的某些 TextView 上,这些 TextView 根据内容扩展为随机大小。经常发生这种情况的一个特殊情况是评论 TextView
.
我尝试过的内容: 我在这里和整个网络上阅读并尝试了许多类似的帖子,但 none 似乎解决了这个问题。许多解决方案包括设置 android:gravity="fill"
和 android:baselineAligned="false"
,它们没有产生影响并已删除或更改回以前的值(在下面的代码中注明)。
下面我提供了特定于评论 TextView
的代码和一张图片,以帮助理解它分开的布局。这是唯一的 TextView
没有与其标签和基线对齐的右侧。这似乎是一个很常见的设置,所以我不确定为什么会出现这个问题。
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/colorWhite"
android:padding="5dp"
android:hint="@string/hint_comment"
android:textSize="12sp"
android:gravity="start|top"
android:ems="10"
android:id="@+id/viewComment"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lbl_View_Comment"
android:layout_marginTop="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"/>
将 android:layout_height="0dp" 更改为 android:layout_height="wrap_content"。
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
android:padding="5dp"
android:hint="@string/hint_comment"
android:textSize="12sp"
android:gravity="start|top"
android:ems="10"
android:id="@+id/viewComment"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lbl_View_Comment"
android:layout_marginTop="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"/>
我的问题: 我无法让最后一行出现在我的某些 TextView 上,这些 TextView 根据内容扩展为随机大小。经常发生这种情况的一个特殊情况是评论 TextView
.
我尝试过的内容: 我在这里和整个网络上阅读并尝试了许多类似的帖子,但 none 似乎解决了这个问题。许多解决方案包括设置 android:gravity="fill"
和 android:baselineAligned="false"
,它们没有产生影响并已删除或更改回以前的值(在下面的代码中注明)。
下面我提供了特定于评论 TextView
的代码和一张图片,以帮助理解它分开的布局。这是唯一的 TextView
没有与其标签和基线对齐的右侧。这似乎是一个很常见的设置,所以我不确定为什么会出现这个问题。
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/colorWhite"
android:padding="5dp"
android:hint="@string/hint_comment"
android:textSize="12sp"
android:gravity="start|top"
android:ems="10"
android:id="@+id/viewComment"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lbl_View_Comment"
android:layout_marginTop="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"/>
将 android:layout_height="0dp" 更改为 android:layout_height="wrap_content"。
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
android:padding="5dp"
android:hint="@string/hint_comment"
android:textSize="12sp"
android:gravity="start|top"
android:ems="10"
android:id="@+id/viewComment"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/lbl_View_Comment"
android:layout_marginTop="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"/>