Paragraph Spacings Using Spannablestringbuilder In Textview
As the question indicates, I am working on a TextView which will show formatted text using SpannableStringBuilder. It has multiple paragraphs and I would like to know what would be
Solution 1:
Implement the LineHeightSpan and override chooseHeight method as follows
@OverridepublicvoidchooseHeight(CharSequence text, int start, int end,
int spanstartv, int v, FontMetricsInt fm) {
Spannedspanned= (Spanned) text;
intst= spanned.getSpanStart(this);
inten= spanned.getSpanEnd(this);
if (start == st) {
fm.ascent -= TOP_SPACING;
fm.top -= TOP_SPACING;
}
if (end == en) {
fm.descent += BOTTOM_SPACING;
fm.bottom += BOTTOM_SPACING;
}
}
Don't forget to add \n at the end of your each paragraph text.
Post a Comment for "Paragraph Spacings Using Spannablestringbuilder In Textview"