On Thu, May 3, 2012 at 6:12 AM, x300 <[email protected]> wrote:
> For the sake of conserving display area, I would like to put "45.6" in
> large font and "km/h" in smaller font on a button.
>
> Aside from making "km/h" a part of background bitmap, which I want to
> avoid as it, too, could change as in "56.7mph", "OVER Speed", "UNDER
> Speed", "67.8miles", "200meters", etc., is there a way?

Try this:

Step #1: Create an HTML string that uses <font size=""> tags to adjust
the font size (e.g., "46.6 <font size="2">km/h</font>")

Step #2: Convert that string into a SpannedString by use of Html.fromHtml()

Step #3: Put that SpannedString as the caption of your button via setText()

You will have to play around with the <font size=""> tag to get things
to look how you want.

Also note that the roster of tags supported by Html.fromHtml()
technically is not documented, so <font size=""> may not work in the
future. That being said, I will be surprised if they eliminate support
for currently-supported tags.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to