TextView 没有椭圆化并且在一行的中间被水平截断

TextView does not ellipsize and is cutoff horizontally in the middle of a line

我已经在这个问题上工作了几个小时,但不知所措。

我在 recyclerview(水平方向)中有一个项目,我有一段文字。我希望文本在适合 TextView 的位置的末尾变成椭圆形,但它却在一个奇怪的地方被截断:

我试过将描述视图设置为固定高度,使用wrap_content,改为使用maxLineslines,它们都产生相同的效果,但没有椭圆化文本。有谁知道我做错了什么?

这一行的代码是:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="point"
            type="uk.geekhole.visum.database.models.BasePoint" />
    </data>

    <androidx.cardview.widget.CardView
        android:layout_width="250dp"
        android:layout_height="260dp"
        android:layout_marginStart="18dp"
        android:layout_marginEnd="9dp"
        android:elevation="0dp"
        app:cardCornerRadius="15dp">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/image"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:scaleType="centerCrop"
                app:imageUrl="@{point.imageUrls[0]}"
                app:layout_constraintBottom_toBottomOf="@id/title"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                tools:background="@android:color/holo_red_dark"
                tools:src="@drawable/app_logo" />

            <View
                android:id="@+id/background"
                android:layout_width="match_parent"
                android:layout_height="105dp"
                android:background="@drawable/background_near_me_row"
                app:layout_constraintBottom_toBottomOf="parent" />

            <TextView
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="20dp"
                android:layout_marginTop="18dp"
                android:layout_marginEnd="20dp"
                android:ellipsize="end"
                android:maxLines="1"
                android:text="@{point.name}"
                android:textColor="@color/text_colour_near_me_title"
                android:textSize="@dimen/text_size_normal"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="@id/background"
                tools:text="Wollaton Hall" />

            <TextView
                android:id="@+id/description"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginStart="20dp"
                android:layout_marginTop="5dp"
                android:layout_marginEnd="20dp"
                android:layout_marginBottom="10dp"
                android:ellipsize="end"
                android:text="@{point.description}"
                android:textColor="@color/text_colour_near_me_description"
                android:textSize="@dimen/text_size_smaller"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintTop_toBottomOf="@id/title"
                tools:text="In the heart of nottingham this stunning park will leave you speechless, with breathtaking views from outside the hall, to the intriguing curiosities inside. Fun for all ages!" />

        </androidx.constraintlayout.widget.ConstraintLayout>
    </androidx.cardview.widget.CardView>
</layout>

使用这个

android:ellipsize="marquee"

正如 Ryan Mentley 在 OP 上发布的那样,这似乎是并解决了问题:Ellipsize not working properly for a multiline TextView with an arbitrary maximum height

不是一个很好的修复,但它完成了工作。