为什么我的文字一到多行就被删掉了?

Why does my text get cut out as soon as it hits multiple lines?

我有一个使用 2 个字符串的简单 RecyclerView。一旦第二个 TextView 获得多行文本,它就会被剪切掉,而不是仅仅扩展视图的高度。

例如,两个 textView 收到的文本是:

"Director":"Cate Shortland"
"Writer":"Jac Schaeffer (story by), Ned Benson (story by), Eric Pearson (screenplay by), Stan Lee (based on the Marvel comics by), Don Heck (based on the Marvel comics by), Don Rico (based on the Marvel comics by)"

我的看法:

<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="wrap_content"
    android:id="@+id/layout">

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/textview"
        android:textSize="18sp"
        app:layout_constraintBottom_toBottomOf="@+id/detial"
        app:layout_constraintStart_toEndOf="@+id/detial" />

    <TextView
        android:id="@+id/detial"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="18dp"
        android:maxWidth="250dp"
        android:text="@string/year"
        android:maxLines="24"
        android:textSize="18sp"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout> 

我尝试从 wrap_content 更改为 match_parent,添加 android:inputType="textMultiLine" 并检查 RecyclerView 是最新版本(因为早期版本存在一些错误) .有什么我可以尝试的想法吗?

将文本视图宽度更改为 match_parent

它与您的文本内容配合得很好

<TextView
    android:id="@+id/detial"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="18dp"
    android:maxWidth="250dp"
    android:text="Jac Schaeffer (story by), Ned Benson (story by), Eric Pearson (screenplay by), Stan Lee (based on the Marvel comics by), Don Heck (based on the Marvel comics by), Don Rico (based on the Marvel comics by)"
    android:maxLines="24"
    android:textSize="18sp"
    app:layout_constraintHorizontal_chainStyle="packed"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
<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="wrap_content"
android:id="@+id/layout">

<TextView
    android:id="@+id/detial"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="18dp"
    android:maxWidth="250dp"
    android:text="@string/year"
    android:maxLines="24"
    android:textSize="18sp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toStartOf="@+id/name"
    app:layout_constraintHorizontal_chainStyle="packed"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<TextView
    android:id="@+id/name"
    android:layout_width="@dimen/match_constraint"
    android:layout_height="wrap_content"
    android:text="text"
    android:textSize="18sp"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@+id/detial" />

</androidx.constraintlayout.widget.ConstraintLayout>