I have a TextView that holds a Spannable string. The string contains a bunch of text, the first word of which is double the typesize as the rest of the string.
The problem is that the line spacing between the first and second line is much larger than the line spacing between subsequent lines due to the increased size of the first word.
http://img.skitch.com/20100615-fwd2aehbsgaby8s2s9psx3wwii.png
The spannable string was created using the following code snippet:
// Price CharSequence text = "$30 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." final Pattern priceRegex = Pattern.compile("^(.[0-9]+)\\s.*"); final Matcher m = priceRegex.matcher(text!=null ? text : ""); if( m.matches() ) { text = new SpannableString(text); ((SpannableString)text).setSpan(new RelativeSizeSpan(2), 0, m.end(1), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); }
How can I fix my TextView so that all lines have the same spacing?
You can try using one of these TextView properties:
android:lineSpacingMultiplier android:lineSpacingExtra
to at least try to make all lines the same height (same as the first one).
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