How To Show Html Codes Inside Textview Or Something Else On Android?
How can I show html source as rendered in TextView or something else? I tried this: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceStat
Solution 1:
HTML support in a TextView is pretty limited, but here is an example of some of the things you can do:
https://github.com/brianjolly/TextFun
The key is escaping the opening bracket in your strings.xml
<stringname="fun_text">I like <font color=\'0x00b0f1\'>BLUE!</font> and <b> Bold</b> and <i> italic</i> and <u> underline</u></string>
And then resetting the text like so:
StringstyledText= tv.getText().toString();
tv.setText(Html.fromHtml(styledText), TextView.BufferType.SPANNABLE);
The beauty of open source is you can see what Html.fromHtml() supports in the android source here: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/text/Html.java
If you're looking to do something more advanced take a look at WebView
Post a Comment for "How To Show Html Codes Inside Textview Or Something Else On Android?"