0

Is there any way to set different fonts for different states in a TextView? Let's say I want Helvetica Regular for normal state, and Helvetica Bold for pressed?

I know how to link a custom font with a text view, but not sure how to do same for multiple fonts and single TextView? Specifically, is there a way to achieve this behaviour through xml?

Update: I'm not looking into workarounds, like having HTML in TextView, or even replacing TextView with WebView. If it's not possible to achieve, I'd rather have one font

Anton
  • 4,395
  • 7
  • 32
  • 46

2 Answers2

0

check this link may help you:

http://shuklaxyz.blogspot.com/2012/05/custom-fonts-for-webview-and-textviewv.html

also :

Custom fonts and XML layouts (Android)

also:

Custom TrueType font from xml only

and this :

http://polwarthlimited.com/2013/05/android-typefaces-including-a-custom-font/

hope that help.

Community
  • 1
  • 1
androidqq6
  • 1,526
  • 2
  • 22
  • 47
0

Using Html.fromHtml comes in handy, but it is limited to the tags you can use. I personally only have used this to do Bold, Colors, italics.
Like this:

String myWords ="<FONT COLOR = "#992211">This is Red:</FONT><br>";
myTextView.setText(Html.fromHtml(myWords));
Tam
  • 1,189
  • 10
  • 15