Home > Back-end >  Textview ellipsize text without dots and cutting last word
Textview ellipsize text without dots and cutting last word

Time:10-21

I'm using android TextView with android:maxLines="1" and trying to use all types of ellipsize, but no one of them does not satisfies my requirements. I want to ellipsize text without adding dots at the and and without cutting whole last word. I want to cut just chars of last word without loosing whole word

<androidx.appcompat.widget.AppCompatTextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@ id/tv_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="4dp"
    android:orientation="vertical"
    android:maxLines="1"
/>

CodePudding user response:

You need next property:

    android:singleLine="true"
    android:ellipsize="none"

Here us your xml:

<androidx.appcompat.widget.AppCompatTextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@ id/tv_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="4dp"
    android:singleLine="true"
    android:ellipsize="none"
    />
  • Related