在Android的设置按钮文字字体 [英] Setting Button text font in android

查看:222
本文介绍了在Android的设置按钮文字字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮采用了android widgets.I要设置的按钮文字字体阖闾67抵达Neue地中海电导率。如何获得这个字体,并设置在Android的布局文件按钮上的文字?

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

推荐答案

首先,你必须把资产的文件夹中的ttf文件,然后你可以用下面的code设置自定义的字体在TextView中,同样的方式,您可以做按钮:

First you have to put the ttf file in assets folder and then You can use the below code to set Custom font in TextView, same way you can do for Button:

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

这篇关于在Android的设置按钮文字字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆