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
To change the font size of a button, use the font-size property.
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.
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With