In my Android project I have to show a spannable text in a text view. The text view is limited to two lines and I'm suppose to ellipsize it. But when I set the spannable string, it causes some problems if the string length exceeds two lines. When it exceeds two lines '...' which is suppose to appear is not showing. And further more it scrolls to the end of the text on touch text.
This is my text view in the layout
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:ellipsize="end" />
This is my code implementation
SpannableStringBuilder spannable = new SpannableStringBuilder(item.getText());
spannable.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
openPost();
}
public void updateDrawState(TextPaint ds) {
ds.setUnderlineText(false);
}
}, getText().length() - getNameLength(),getText().length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
notificationText.setText(spannable, TextView.BufferType.SPANNABLE);
notificationText.setMovementMethod(LinkMovementMethod.getInstance());
How can I fix this