Sunday, July 28, 2013

How to add color to a little bit of XML string resource, in Android?

I want to show a programming tutorial. A little code a little explanation, and so on. I want to display the code in some other color. The trouble is: I have dozens of different tutorials.

I can't go around making separate activities for each of them with a little normal text in one textview, a little colored text in another one, that's just terrible, plus I'd then have like 30 textviews.

<string name="sbegw">    Normal Text.     <some color tag="#012345"> Colored Text </some color tag> </string> 

This is what I'm looking for: an attribute that I can simply insert in my string resource at places where I want it.

The normal text above should appear normally, and the colored text should be colored (obviously). I have tried several attributes, I can't even get some text to look "Bold" or underlined using <b></b> or <u></u> or something like this?

Is any formatting possible in XML? Or can I only get plain boring text?

Is something like this possible in XML (Android)? How to do it?

Source: http://stackoverflow.com/questions/17894885/how-to-add-color-to-a-little-bit-of-xml-string-resource-in-android

National Tequila Day Prince William Last Name Prince George Mexico vs Panama The Dirty Royal Baby Pictures Kensington Palace

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.