0

I have body code:

<TextView
    android:maxLines="3"
    android:ellipsize="end"
    android:textColor="@color/text_grey"
    android:textSize="@dimen/text_size_normal"
    android:textAppearance="@style/FontPath.Light"
    android:id="@+id/tv_content_notification"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

I using android:ellipsize="end" but when running it displays the following:

enter image description here

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96

1 Answers1

0

Try this way it will work

android:maxLines="3"
android:ellipsize="end"
android:singleLine="false"

OR

try to use ViewTreeObserver and you need to calculate lines fit into textview with its height and then set maxlength

ViewTreeObserver observer = textView.getViewTreeObserver();
observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
    @Override
    public void onGlobalLayout() {
        int maxLines = (int) textView.getHeight()
                / textView.getLineHeight();
        textView.setMaxLines(maxLines);
        textView.getViewTreeObserver().removeGlobalOnLayoutListener(
                this);
    }
});
Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96