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!


Filed under: Product Engineering | Topics: android, android developers, developers, html, mobile, platforms

B2B Distribution Technology

Sign up for our weekly newsletter covering B2B technology innovation


Top Posts

  • B2B Chemical Marketplaces and Tech Startups: Landscape and State of the Industry

    Read more

  • Platform vs. Linear: Business Models 101

    Read more

  • Amazon Business – 2020 Report

    Read more

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

    Read more

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

    Read more