Monday, 10 April 2017

Display HTML in TextView?


You need to use Html.fromHtml() to use HTML in your XML Strings. 

For example (< Android Nougat):

myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));


For example (>= Android Nougat):

myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>", Html.FROM_HTML_MODE_COMPACT));


To differentiate between Android versions use Build.VERSION.SDK_INT >= Build.VERSION_CODES.N

No comments:

Post a Comment

Run/install/debug Android applications over Wi-Fi ?

Open Teminal/cmd --------------- Below steps is for Android 10 or lower Step 1 - Connect the device via USB and make sure debugging is work...