So the other day, I ran into a situation where I needed an Android TextView, which, had a portion of the text that was bold and a portion that wasn’t bold. My first thought was….okay two TextViews side by side, that will do the trick. Unfortunately, my layout was filled with nested LinearLayouts, RelativeLayouts, LinearLayouts, and so on and so forth. Everytime I tried to make a RelativeLayout or LinearLayout with a horizontal orientation something would break on my screen. I was beyond frustrated. Then I stumbled upon the HTML class. The HTML class uses TagSoup to take care of nasty HTML formatting and renders the text in HTML format. All you need to do is call Html.fromHTML(“<b> my string </b>”) !! Its as simple as that, then you have nicely formatted text!
Filed under: Product Engineering | Topics: android, android developers, developers, html, mobile, platforms