Implement the LineHeightSpan method and override chooseHeight as follows
@Override public void chooseHeight(CharSequence text, int start, int end, int spanstartv, int v, FontMetricsInt fm) { Spanned spanned = (Spanned) text; int st = spanned.getSpanStart(this); int en = 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; } }
Remember to add \n to the end of your text for each paragraph.
source share