TextView Html Formatting

I have a textview that should display its content with HTML formatting. From the code, this can be done as follows:

textView.setText(Html.fromHtml(someText));

Is there any way to do this through XML?

I ask because I do not want to set the text through the code. In my case, the text comes from the database call and is displayed through the adapter.

+3
source share
1 answer

Yes there is a bunch of (simple) tags that TextView understands - if the text is set to XML from a string resource.

So basically

<TextView text="@string/foo" .. />

You can also provide templates such as "Hello <b>%s</b>", but here you still need to run some code to fill in the value for%s

http://developer.android.com/guide/topics/resources/string-resource.html .

+1

Source: https://habr.com/ru/post/1792840/


All Articles