Android Display Html in TextView

July 22, 2018
fun fromHtml(html: String): Spanned {
    return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        Html.fromHtml(html, Html.FROM_HTML_MODE_LEGACY)
    } else {
        @Suppress("DEPRECATION")
        Html.fromHtml(html)
    }
}

textView.text = fromHtml(htmlText)
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.