0

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

1
  • @Mark: i've edited the problem to make it more understandble. :) Commented Apr 29, 2011 at 9:38

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

can you give a small example i'm a newbie to android and still learning
Not really. As I said in my answer, writing a text justification routine "will not be a trivial task"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.