问题
I have added an external font in /assets directory, and manually doing setFacetype(font). Isn't there a general way to set the whole application to use a specific font if you have added it external? Or do you have to use Android's selected fonts in order to achieve this?
回答1:
You cannot use your custom fonts through to whole application in a general way.
You cannot set your custom fonts through xml files.
You have to use the Typeface
functions in your code to use your custom fonts within your application.
回答2:
tv=(TextView)findViewById(res);
Typeface font = Typeface.createFromAsset(this.getAssets(), "MYFONT.TTF");
tv.setTypeface(font);
This also how to use it in a textview.
For whole application go to Using a custom typeface in Android.
and go to Manish Singla answer
回答3:
Typeface mTypeface = Typeface.createFromAsset(getAssets(), "YOUR FONT NAME");
textview.setTypeface(mTypeface, Typeface.NORMAL);
来源:https://stackoverflow.com/questions/9531110/android-fonts-in-application