-3

I have a textview with the property

android:maxLines="1"

In case the text is too long it truncates and add the three dots. i.e

If I want to put the text (including the quotes) "hello world one two three four"

It will display

"hello world one two....

but I would like to display the closing quote.

"hello world one two..."

How to achieve this??

Kenenisa Bekele
  • 835
  • 13
  • 34
  • You have to do it with two textViews only I guess. One with the truncated one and at the end text view with the quote. – hasan_shaikh May 23 '18 at 10:23
  • detecting if textview is ellipsized might help : https://stackoverflow.com/questions/4005933/how-do-i-tell-if-my-textview-has-been-ellipsized – Sahil May 23 '18 at 10:27

1 Answers1

0
<TextView
    android:id="@+id/activity_main_tv_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/text"
    />

And in your activity,

val stringText = "hello world one two three four"
findViewById<TextView>(R.id.activity_main_tv_text).text = String.format("\"%s\"", stringText)

enter image description here

Shubham Raitka
  • 1,034
  • 8
  • 15