约束布局的最后一个视图被裁剪了

3
在我的布局中,最后一个视图(蓝色文本)被裁剪,如下图所示。

enter image description here

我已经按照以下方式设置了我的ConstraintLayout

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="wrap_content">

   <ImageView
        android:id="@+id/ivIcon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="10dp"
        android:background="@color/blue"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <TextView
        android:id="@+id/tvMain"
        style="@style/ActorTextMainOne"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:layout_marginTop="28dp"
        android:text="28"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <TextView
        android:id="@+id/tvSecondaryOne"
        style="@style/ActorTextSecondary"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="4dp"
        android:text="Jun"
        app:layout_constraintBottom_toTopOf="@+id/tvSecondaryTwo"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/tvMain"/>

    <TextView
        android:id="@+id/tvSecondaryTwo"
        style="@style/ActorTextSecondary"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="12dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="4dp"
        android:text="2017"
        app:layout_constraintBottom_toBottomOf="@+id/tvMain"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/tvMain"/>

    <TextView
        android:id="@+id/tvDescription"
        style="@style/ActorTextDescription"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="4dp"
        android:text="@string/arrival_date"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="@+id/tvMain"
        app:layout_constraintTop_toBottomOf="@+id/tvSecondaryTwo"/>

</android.support.constraint.ConstraintLayout>

使用的ConstraintLayout版本为1.0.2。

我觉得我错过了一些显而易见的东西,但我无法弄清楚。如何使底部的蓝色文本完全可见,同时保持ConstraintLayout的高度为wrap_content

1个回答

1
尝试更改。
app:layout_constraintTop_toBottomOf="@+id/tvSecondaryTwo"

app:layout_constraintTop_toBottomOf="@+id/tvMain"

针对id为tvDescription的TextView

这将使得id为tvDescription的TextView位于id为tvMain的TextView下方。


这确实显示了整个蓝色文本。然而,它被限制在tvSecondaryTwo上,以克服tvMain导致的额外底部空间。抱歉,在我的原始问题中我没有提到这一点。您能否解释一下为什么针对tvSecondaryTwo进行约束时它无法工作? - Much Overflow
我不明白“tvMain引起的额外空间”是什么意思? - Raghunandan
大的TextView导致额外的顶部和底部填充。与此处提问的问题相同 https://dev59.com/imw15IYBdhLWcg3wd7lj - Much Overflow
TextView的宽度为wrap_content。但是如果你增加了字体大小,你会看到那个空间。TextView在xml中没有文本填充。你可以尝试链接中提到的解决方案。我还没有尝试过那里提到的任何解决方案。 - Raghunandan
@MuchOverflow,如果你使用tvSecondaryTwo,你可以看一下它的效果https://imgur.com/8xj9SOU。textMain会截断你的tvDescription。空间问题与constraintlayout无关,而是与textview及其大小有关。 - Raghunandan
非常感谢您。感谢您的帮助! - Much Overflow

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接