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

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

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

enter image description here

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

"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是否为最新版本(某些早期版本具有的错误)。有什么想法可以尝试吗?

android android-recyclerview textview android-wrap-content
1个回答
0
投票

将您的textview宽度更改为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" />
© www.soinside.com 2019 - 2024. All rights reserved.