0

In my XML values strings code, I have a string with some text that I want to have only a few of the words in color. I also want to have a new line for some of the text.

I can do things like: < b> my bold text < /b> and that works (leading space added for this post).

I try to tag the text with color but no color shows up and there are no errors.

name="dogs"
    >Red Dog, <color foreground="#FFFF0000"> Sammy</color></string>

I also try adding a new line - I've tried things like:
< LF> some text, space at beginning only for this post < /LF>
< CR> this didn't work either < /CR>
< p> some text, space at beginning only for this post < p>

But, no new paragraph / new line, carriage rtn happens.

What am I doing wrong? Or, more correctly put, How do I accomplish this?
Thanks

3
  • Could you update your post to include the relevant Java code where this string resource is used? Are you using the fromHTML() function? Commented Oct 8, 2010 at 18:25
  • The string is not being called from java code. The layout xml has a TextView and the string is being called from that TextView's 'Text' property. The string is correctly called, the only thing is no colors or newline. Other formats, such as bold, italic work. Commented Oct 8, 2010 at 18:57
  • Ahh, I see. You won't like my answer then :) Commented Oct 8, 2010 at 20:44

1 Answer 1

3

As per the documentation, the three supported HTML tags for values in the strings.xml are (without fromHTML()):

<b>
<i>
<u>

As for a new line, you could try a bare \n. I remember at least one folk reporting it worked.

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

2 Comments

Thanks - that's what I discovered, too. Darn. Too bad it doesn't generate an error so it would be obvious. However, the \n did work! Which surprises me. I think I'll try out some of the other format things used in pure code. Thanks again!
You need to put this int @strings.xml in order for this to work.

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.