Ellipse Ice Cream Sandwich Adds [

I am currently developing an application and just starting some testing for an ice cream sandwich and notice some strange behavior when using the android: ellipsize = "end" property in text form. he adds a character after the dots. This mistake leads me to nuts and appears only in a sandwich with ice cream. I saw a previous thread about this , but none of the fixes there helped. Any ideas, but a report for Android 4.0 maybe? My code is below incase, I kind of put an ice cream sandwich.

<LinearLayout android:id="@+id/mainTitleLayout" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="0.36" android:orientation="horizontal" android:weightSum="1" > <TextView android:id="@+id/mainTitle" android:layout_width="135dp" android:layout_height="wrap_content" android:layout_marginLeft="62dp" android:layout_marginTop="4dp" android:layout_weight="0.53" android:editable="false" android:ellipsize="end" android:gravity="center_vertical|center_horizontal" android:singleLine="true" android:textColor="#fff" android:textSize="26sp" android:textStyle="bold" android:width="125dp" > </TextView> </LinearLayout> 

I set the text dynamically in code through

 TextView title = (TextView) act.findViewById(R.id.mainTitle); title.setTypeface(Utils.font); title.setText(detailTitle); 
+4
source share
3 answers

I think I know your problem. I found this problem with my special font that I installed through setTypeface. The answer is found in the source code of the Layout , which processes the drawing of TextViews on the screen. Take a look at the ellipse method in ling 1668. In addition to the dotted character, a character is used, a space with a width of 0 (U + FEFF). I assume that your custom font does not include the space character 0 width, which causes the window to render. I have the same problem! The fix will require modifying the .ttf or .otf file to include a 0-width space character. Hope this helps!

+6
source

I had a similar problem using a special font in TextView, actually in 1.6. In my case, I replaced the standard TextView with the version in this link:

multi-line text for Android with ellipsis

and additional characters are gone.

+1
source

If I were you, I would try minLines and maxlines inside a TextView ad like this:

 android:minLines="1" android:maxLines="1" 

instead of android: singleLine = "true". I had a similar problem that occurred only when using android 4. I solved it this way, but I did not change the font through setTypeface.

0
source

Source: https://habr.com/ru/post/1389422/


All Articles