1

I've been working on this issue for a few hours now and am at a loss.

I have an item in a recyclerview (orientation horizontal) that with which I have a paragraph of text. I'm expecting the text to ellipsize at the end of where it would fit into the TextView, but instead it gets cut off in a weird place: enter image description here

I've tried setting the description view to a fixed height, used wrap_content, changed to use maxLines, lines and all of them produce the same effect and do not ellipsize the text. Does anyone know what I'm doing wrong with this?

The code for this row is:

<?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>
Ryan M
  • 18,333
  • 31
  • 67
  • 74
Zurvæ
  • 610
  • 1
  • 8
  • 23
  • What happens if you change `description`'s width to `0dp` and add constraints to the start end to attach to the `parent`? – Ben P. Feb 20 '20 at 21:10
  • Which device is doing this problem? – DemoDemo Feb 20 '20 at 21:17
  • @BenP. I have also tried that and unfortunately it didn’t work. – Zurvæ Feb 20 '20 at 21:31
  • 2
    Does this answer your question? [Ellipsize not working properly for a multiline TextView with an arbitrary maximum height](https://stackoverflow.com/questions/14173776/ellipsize-not-working-properly-for-a-multiline-textview-with-an-arbitrary-maximu) – Ryan M Feb 21 '20 at 00:44
  • @RyanMentley that does indeed appear to be / fix the issue. A shame that it's such a hacky fix though. Thanks! – Zurvæ Feb 21 '20 at 10:51

2 Answers2

0

As posted by Ryan Mentley on the OP this appears to be and fix the issue: Ellipsize not working properly for a multiline TextView with an arbitrary maximum height

Not a very nice fix but it does the job.

Zurvæ
  • 610
  • 1
  • 8
  • 23
-1

Use this

android:ellipsize="marquee"