Setting Button text font in android

Ajn picture Ajn · Jun 16, 2011 · Viewed 50.7k times · Source

I have a button created using android widgets. I want to set the font of the button text to Helv Neue 67 Med Cond. How to get this font and set it to the button text in android layout file?

Answer

Ann picture Ann · Aug 15, 2013

I guess you may have already found the answer, but if not (and for other developers), you can do it like this:

1.you want to save the "Helv Neue 67 Med Cond.ttf" in to assets folder. then

For TextView

  TextView txt = (TextView) findViewById(R.id.custom_font);
  Typeface typeface = Typeface.createFromAsset(getAssets(), "Helv Neue 67 Med Cond.ttf");
  txt.setTypeface(typeface);

For Button

  Button n=(Button) findViewById(R.id.button1);
  Typeface typeface = Typeface.createFromAsset(getAssets(), "Helv Neue 67 Med Cond.ttf");
  n.setText("show");
  n.setTypeface(typeface);