0

I know to set Typeface from coding like below.

type1=Typeface.createFromAsset(getAssets(),"fonts/helveticaneueLtstd-bd.otf");
text.setTpeface(type1);

But it is difficult to me to set Typeface if I have more text views. How can I set the typeface from XML instead of from coding?

Sagar Zala
  • 4,854
  • 9
  • 34
  • 62
koti
  • 3,681
  • 5
  • 34
  • 58

2 Answers2

2

In the xml layout you can only use normal, sans, serif and monospace as fonts. Any other font will have to be set in code like you did.

You could extend TextView(and use that class instead of the plainTextView in the xml layout) and implement a custom attribute that could take another font, other than the fonts I listed above.

user
  • 86,916
  • 18
  • 197
  • 190
0

Hi. Sorry, you can not set custom typeface using XML.

Michal
  • 3,262
  • 4
  • 30
  • 50
Zumbarlal Saindane
  • 1,199
  • 11
  • 24