34
votes

I use <font size ="50"> tag in android textview like this

resultTextView.setText(Html.fromHtml("<font size='50' color='#337744'>Text Message</font>"));
resultTextView.setText(Html.fromHtml("<font size=\"50\" color='#337744'>Text Message</font>"));

but the problem is the color tag works but size tag doesn't work

In this blog http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html

it is given that font size tag works. What's wrong in my code?

3
[follow the link and check my answer ](stackoverflow.com/questions/7739775/…) - Avinash Ajay Pandey

3 Answers

54
votes

There is exact question Using size HTML attribute in TextView . It says it ignores the size. You can use use <small> for smaller text and so on. <font> only supports color and face attributes. see android.text.Html (on GrepCode) and How to apply font size while rendering HTML code in Android or Java and TextView with different textSize for more. Hope it helps in someway.

29
votes

If you need only different size, you can use simple <small> or <big> and you can use it more times for one char.
Example: "clasic text is ok, but <big>bigger <big>is <big> better</big></big></big>" You can use <h1> etc. too, but here is problem with margins.

2
votes

Try this one,Its working for me,use small,big key words

TextView mBox = (TextView) findViewById(R.id.txt);
    mBox.setText(Html.fromHtml("<font color=#cc0029>" + "<b>"
            + "Hiiiiiiiiii" + "</b>" + "<br />" + "<small>" + "description"
            + "</small>" + "<br />" + "<small>" + "DateAdded" + "</small>"));