Product Engineering // Blog

Android TextViews – with HTML!

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!

Weekly Industry Newsletter

Top Posts

  • Platform Business Model – Definition | What is it? | Explanation

    Read more

  • Platform vs. Linear: Business Models 101

    Read more

  • White Paper: Development Platforms and the Next Wave of App Innovation

    Read more

  • Amazon Business: Understanding the Threat to B2B Distributors

    Read more

  • The Value of Digital Transformation: How Investors Evaluate “Tech”

    Read more

Read articles by