Ellipse does not work

I have a TextView that I set for text using setText (). In the properties, I set:

Ellipsize = END Lines = 1 Gravity = Left Scroll Horizontal = False 

But this fragment adds additional text (the text of the clips since the last space was found). But do not include dots ("...") at the end.

Example:

 ------------------------------- | | Hi how are you ? And where are you now ? | | | | 

After clipping:

 ------------------------------- | | Hi how are you ? And where | | | | 

What I want:

 ------------------------------- | | Hi how are you ? And where... | | | | 

I am using Android 1.6. Help Plz.

+7
source share
4 answers

android:singleLine="true" and textView.setEllipsize(TruncateAt.END);

These are two key elements to achieving this.

+15
source
  android:singleLine 

outdated .

This is what the documentation says:

"This attribute is deprecated and replaced with textMultiLine in the inputType attribute. Use caution if changing existing layouts because the default value of singeLine is false (multi-line mode), but if you specify any value for inputType, single-line mode is used by default. (If and singleLine, and inputType attributes are found, inputType flags override the value of SingleLine.). [Boolean] "

To solve your problem. You can use the following:

  android:ellipsize="end" android:maxLines="1" 
+3
source

Textview has a call to the singleLine property to make it true in your XML file.

If you make code,

 textView.setSingleLine(true); 
+2
source

work here for me

 android:ellipsize="end" android:singleLine="true" 
+1
source

All Articles