4

I have TextView defined for example as follows:

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:maxLines="1"
        android:ellipsize="end"
        android:text="This is very long text"
        android:textSize="34pt"/>

Using API level 14/15 this leads to cut whole word "very", and I have actually text displayed "This is", but I need to cut this text like "This is ver".

Can some one ask me how to achieve such behavior?

alex
  • 81
  • 4

1 Answers1

4

Use the properties singleline and ellipsize:

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:text="This is very long text"
    android:textSize="34pt"/>
Bhawna Raheja
  • 619
  • 4
  • 11
  • 2
    is there any solution for this not using the deprecated singleLine attribute? – Tobias Reich Mar 08 '17 at 10:52
  • @TobiasReich android:maxLines="1" – Dmitriy May 03 '17 at 11:18
  • 2
    Problem is, maxLines sets the amount of lines to 1. But it breaks the line at whole words. Single line does this by using the dots. So when having "this is a test" it might look like "this is a" (omitting test) but singleLine looks like "this is a te..." – Tobias Reich May 03 '17 at 11:23