I am trying to format a TextView with lots of text to look better, and since I feel this is very easy with HTML and CSS I thought I'd give it a go. And since having it in values/strings.xml lets you localize, I found this to be the best option. Now, I manage to get HTML in a string fine with:
<![CDATA[ <html code here> ]]>
But if I try for example:
<![CDATA[
<html>
<head>
<body>
<style type=\"text/css\">
p {
display: block;
border-bottom: 1px solid #31B6E7; }
</style>
</head>
...
etc
]]>
It will just paste the CSS code as plain text, is it not possible to format using CSS this way or does anyone have a good tip for me here?
Thanks for any help on this one.
I think you're perhaps expecting a little much from the TextView, or rather, from the Html.fromHtml method, since that is what turns the HTML into a Spannable that you can use with the TextView. It's quite basic. Here's what it supports:
http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With