I have a TextView which i set the text using setText(). In properties, I have set:
Ellipsize = END
Lines = 1
Gravity = Left
Scroll Horizontal = False
But this clips extra text (clips text since where last space is 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. Plz help.
android:singleLine="true"
and textView.setEllipsize(TruncateAt.END);
These are the two key elements to achieve that.
android:singleLine
is deprecated.
Here is what the documentation says:
"This attribute is deprecated and is replaced by the textMultiLine flag in the inputType attribute. Use caution when altering existing layouts, as the default value of singeLine is false (multi-line mode), but if you specify any value for inputType, the default is single-line mode. (If both singleLine and inputType attributes are found, the inputType flags will override the value of singleLine.). [boolean]"
To solve your problem. You can use the following:
android:ellipsize="end"
android:maxLines="1"
Textview
has a property call singleLine
make it true
in your XML file.
If you are doing through code then
textView.setSingleLine(true);
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