3

I convert HTML string to spannable by using HtmlCompat.fromHtml(...), the ImageGetter I use simply uses Glide to download images. By using ContextCompat.getDrawable(...) for comparison it gives similar result indeed.

In emulator with API level 16, it displays correctly like this:

ImageSpan in API 16

However in emulator with API level 28 it gives extra space above the image like this:

ImageSpan in API 28

Would anyone help me solving this inconsistency problem? Thank you.


Code snippet

val spanned = HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_LEGACY, Html.ImageGetter {
    ContextCompat.getDrawable(context, drawableResId)?.apply {
        setBounds(0, 0, intrinsicWidth, intrinsicHeight)
    }
}, tagHandler)
fikr4n
  • 3,250
  • 1
  • 25
  • 46

0 Answers0