I want to clip extra text from text view. I want this type of look.
Hello! Asad you are a go...
instead of
Hello! Asad you are a good boy. Where do you live?
is that possible in android?
I want to clip extra text from text view. I want this type of look.
Hello! Asad you are a go...
instead of
Hello! Asad you are a good boy. Where do you live?
is that possible in android?
Using this
Rect bounds = new Rect();
Paint textPaint = textView.getPaint();
textPaint.getTextBounds(text,0,text.length(),bounds);
int height = bounds.height();
int width = bounds.width();
from this post. How to get string width on Android?
You can calculate then if the width (pixel width) of the text is less then the width of the text view, if so then use ... If not then display full message.
or this
<TextView
android:id="@+id/text_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1" />
From this post Clipping extra text which is getting out of bounds TEXT VIEW :: ANDROID