开发者

Easiest way to format text bullets in textview on Android

I looked around but did not find anything suitabe to just format text like this on Android textvie开发者_如何学Pythonw.

  • text that is in one line

  • text that is longer and will

    continue on next line with automatic indentation

  • and so on...

That's it already. Thanks very much!


Yeah, there are no really good typographic features in Android -- no full justification, bullets, leading, etc. -- so one thing I've seen suggested for this is to simply use a WebView, and then just insert the proper HTML, e.g.:

<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>

I do not know if direct HTML does hanging indents like you're asking, but there's probably a CSS property you could use that Android's WebView will support.


You can format TextView like you do for a HTML page using Html.fromHtml. Check below snippet for more details...

String test1 = "<ul><li>Item 1</li><li>Item 2</li></ul>";
Spanned s = Html.fromHtml(test1);
tv.setText(s);

However, TextView doesn't support all HTML Tags. Check below Mark Murply's commonsware link for supported tags by TextView.

http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜