Android开发LCD字体

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2878882/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:42:21  来源:igfitidea点击:

Android develop LCD font

androidfonts

提问by user345602

How to add additional font in android environment? I need to make a font like LCD with pale background numbers like this:

如何在android环境中添加额外的字体?我需要制作一个像 LCD 这样带有浅色背景数字的字体,如下所示:

http://www.androidfreeware.net/img2/gps_speedometer_android_1.png

http://www.androidfreeware.net/img2/gps_speedometer_android_1.png

回答by the100rabh

We at bangalore android developers grouphad done this for one of our project AutoMeterYou can have a look at the code there in detail.

我们班加罗尔 android 开发人员小组为我们的一个项目AutoMeter完成了这项工作,您可以详细查看那里的代码。

The code would look something like this

代码看起来像这样

Typeface myTypeface = Typeface.createFromAsset(this.getAssets(),"DS-DIGIB.TTF");
waitingTimeView = (TextView) findViewById(R.id.WaitingTime);
waitingTimeView.setTypeface(myTypeface);

DS-DIGIB.TTF is the font put in the assets folder

DS-DIGIB.TTF 是放在assets文件夹中的字体

回答by ios developer

public void setFontTextView(Context c, TextView name) {
Typeface font = Typeface.createFromAsset(c.getAssets(),"fonts/Arial.ttf");
name.setTypeface(font);
}

Download Arial font in ttf file formate and put in asset folder. Thats enough.

下载 ttf 文件格式的 Arial 字体并放入资产文件夹。够了。

回答by Yann Ramin

You want to use the android.graphics.Typefaceclass, which can create new Typefaces from assets or files.

您想使用android.graphics.Typeface类,它可以从资产或文件创建新的字体。