4

I'm trying to format text in string, which is displyed in TextView.

<string name="register"> <p align="center"><u><b><i>Something</i></b></u></p> 
                         <p align="right">Blablabla</p>

Underline, bolt and italics are working, but new paragraph and align isn't. Am I doing something wrong? Is there some other tag for end of a paragraph/new line?

mmBs
  • 8,421
  • 6
  • 38
  • 46
user3860990
  • 49
  • 1
  • 1
  • 3
  • not all the html tags are supported by the method Html.fromHtml – Blackbelt Jul 22 '14 at 08:36
  • Possible duplicate of [write a paragraph using textview in android](http://stackoverflow.com/questions/5040574/write-a-paragraph-using-textview-in-android) + http://stackoverflow.com/questions/9754076/which-html-tags-are-supported-by-android-textview + http://stackoverflow.com/questions/1529068/is-it-possible-to-have-multiple-styles-inside-a-textview – Ciro Santilli OurBigBook.com Feb 08 '16 at 13:38

2 Answers2

4

Refer here http://bigknol.com/android-supported-html-tags-textview-string/

Not all html tags are supported in android. As per the link only the following tags are supported:

<big></big>
<small></small>
<bold></bold>
<strike></strike>
<a href=””></a>
<sup></sup>
<sub></sub>
<u></u>
<i></i>
<tt></tt>

Also refer here Which HTML tags are supported by Android TextView? Another reference is here http://javatechig.com/android/display-html-in-android-textview

Community
  • 1
  • 1
ngrashia
  • 9,869
  • 5
  • 43
  • 58
4

You can use

myTextView.setText(Html.fromHtml("<h2>Heading</h2><br><p>data about something</p>"));
George Thomas
  • 4,566
  • 5
  • 30
  • 65