TextView ellipsize and broken symbols

android, android-layout

Solution

There is a issue logged here. Many people have some or the other problem when using `TextView` with ellipsize in a `ListView`. There are many workarounds that suggest changing the textview to single line, but you cant use that.

Try setting the `android:maxLines="2"` attribute.

Update:

Use TextUtils.ellipsize API to manually ellipsize the string before setting it to the textview. See whether the ellipsized string returned by this API contains the square char at the end.

Usage sample code:

TextPaint tp = new TextPaint();
tp.setTextSize(float textSize);
tp.setTypeface(Typeface typeface);
Charsequence elipText;
elipText = TextUtils.ellipsize ( text, tp, avail, TextUtils.TruncateAt.END);
textview.setText(elipText);

Problem

I have some problem with standard android ellipsize mechanism. My textview xml layout is next: ``` <TextView android:id="@+id/something" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/message_test_text" android:lines="2" android:ellipsize="end" android:textColor="@drawable/dialogs_text_selector" /> ``` Then in code I'm setting Helvetica typeface to this field. And then, in the end of second line I see broken symbol after dots: Because it used in list, I see a list of squares. Can I remove it without tons of code? Thank you!

Original source

Related problems