I’ve got a list view in which i have to dispaly some text from html with proper formatting. Though i pass the html as string to Html.fromHtml method but my formatting as align=”justify” don’t work.
here is the code snippet:
String text = "<ul><li><p><div align="justify">as part of its growth plan, the ranchi-based central coalfields ltd (ccl) is gearing up to double the company's production in the next couple of years and also to increase the capacity of coal washeries.</div></p></li></ul>";
i pass this this string to
Spanned nText = Html.fromHtml(text);
and then i display it on the screen
When String nText displays on the emulator screen the formatting that should be there, i.e. the text should be displayed as justified, is gone.
Please help
I have found that using Html.fromHtml() can be somewhat hit and miss because some html tags are supported, and others are not. Justified text is not generally supported within Android mainly because, I suspect, that it can look pretty dreadful with relatively short lines of text. It would not surprise me if justified text is not supported in fromHtml().
Personally I would avoid justified text on a small screen anyway because it can be difficult to read.
If you really need justified text, I think that you may need to write something which implements android.text.style.AlignmentSpan and write your own text justification routine, which will not be a trivial task.