Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Help with Changing Button Font Type, How?

Tags:

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

like image 428
Lucy Avatar asked Mar 31 '11 08:03

Lucy


People also ask

How do I change the font on my button text?

To change the font size of a button, use the font-size property.

How do I create a button style in Android?

To add a button, that has an Android style all you need to do is to drag and drop a button from the Palette to your layout. For most versions that would mean a grey button with all corners at 2dp roundness. Check our blog, if you need to learn more about using Android Studio Layout Editor.

What font do buttons use?

Font. Sans-serif font is the standard for all kinds of buttons. That's because sans-serif fonts are very readable for every online usage.


1 Answers

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);
like image 140
Konstantin Burov Avatar answered Sep 28 '22 11:09

Konstantin Burov