Android develop LCD font

2019-01-22 10:00发布

问题:

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

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

回答1:

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.



回答2:

We at bangalore android developers group had done this for one of our project AutoMeter You can have a look at the code there in detail.

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



回答3:

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



标签: android fonts