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!
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.
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);
The problem here I don't think it was your code. The problem is your .tff
file which is missing the ellipsize
character, hence the square
is displayed. Your font was not... let's say mobile optimized
.
Class here solving problem very well
Then in code I'm setting Helvetica typeface to this field
Hopefully you have paid for a license for this font. Otherwise, please do not distribute it.
And then, in the end of second line I see broken symbol after dots:
This has been covered before, such as: Android How to get rid of question mark at end of ellipsize
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With