I have several TextViews in a row and I want the 1st TextView to take up all spare space but if the combined length of the TextViews is too long to fit on one line, I want the 1st TextView to be cut off.
As for the spare space I have set the 1st TextView's layout_width to match parent and layout_weight to 1 which works. I just can't get it to cut off any extra letters so it fits on one row.
What I want is something like the following with 'Text' and 'Long Text'
'Text :data'
'Long T :data'
So 'Long Text' gets cut off to 'Long T' in order to fit.
What I get is
'Text :data'
'Long Text :d'
Thanks!
Give the first (left) TextView a set size (set in relative terms, dp), or use maxWidth for it, and also use ellipsize.
http://developer.android.com/reference/android/widget/TextView.html#attr_android:ellipsize
This is a good answer to your problem: TextView cuts off text when it is long enough
Also, seems similar to this question which may help: Two TextViews side by side, only one to ellipsize?
Try something like this:
android:singleLine="true"
android:ellipsize="start"
android:scrollHorizontally="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