Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lineSpacingMultiplier and maxLines cuts last line, android textview

I would like to set android:lineSpacingMultiplier=0.7 and have android:maxLines=3 for TextView. It works when text is not longer than 3 lines, but when text is longer than 3 lines it cuts part of last line (see image on imgshack: IMAGE)

Same thing happens when using in code textView.setLineSpacing(0, 0.7f).
Tried to extend TextView height and make font smaller, both ideas failed - still cuts last line.

Any thoughs?

like image 683
user1039411 Avatar asked Dec 23 '11 10:12

user1039411


1 Answers

This appears to be a bug in the text view class in Android. Unfortunately all that is available are only workarounds, as far as I know.

There is a workaround where you measure dynamically how much lines your text will need in the text view and set the 'maxLines' dynamically.

There is another workaround where you 'mislead' the view 'telling' it it is has a bit more height (override onMeasure)

See TextView last line drawn in half

None of these are ideal unfortunately.

like image 144
George Avatar answered Nov 17 '22 12:11

George