Android Help with Changing Button Font Type, How?

Lucy picture Lucy · Mar 31, 2011 · Viewed 27.2k times · Source

i would like to change the font that appears on the button text, i have managed to do this with text on the screen, textview, but cannot find any info, or help with applying this to a button.

I 'am novice, so providing the code to do so, would be much appreciated. This is what i'am using for the textview, but how do i change the button font?

TextView txt = (TextView) findViewById(R.id.custom_font);  
Typeface font = Typeface.createFromAsset(getAssets(), "1543Humane_jenson_bold.TTF");  
txt.setTypeface(font);

Thanks Lucy x

Answer

Konstantin Burov picture Konstantin Burov · Mar 31, 2011

Button IS-A TextView, so just do it as with a TextView:

Button txt = (Button) findViewById(R.id.custom_font);  
Typeface font = Typeface.createFromAsset(getAssets(), "1543Humane_jenson_bold.TTF");  
txt.setTypeface(font);