在Android的设置按钮文字字体按钮、字体、文字、Android

2023-09-07 04:18:12 作者:咎由自取

我有一个按钮采用了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);