Skip to content

Instantly share code, notes, and snippets.

@mrmike
mrmike / gist:77fe2a6a357e78108115
Last active November 30, 2023 00:20
Remove extra space from Android spannable
private void setText(String html) {
SpannableStringBuilder spanned = (SpannableStringBuilder) Html.fromHtml(html);
spanned = trimSpannable(spanned);
mTextView.setText(spanned, TextView.BufferType.SPANNABLE);
}
private SpannableStringBuilder trimSpannable(SpannableStringBuilder spannable) {
checkNotNull(spannable);
int trimStart = 0;
int trimEnd = 0;