Carnal
Carnal

Reputation: 22064

Android - Fonts in Application

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?

Upvotes: 0

Views: 1083

Answers (3)

C.d.
C.d.

Reputation: 9995

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.

Upvotes: 3

Bhavesh Vadalia
Bhavesh Vadalia

Reputation: 369

Typeface mTypeface =  Typeface.createFromAsset(getAssets(), "YOUR FONT NAME");
textview.setTypeface(mTypeface, Typeface.NORMAL);

Upvotes: 2

Bigflow
Bigflow

Reputation: 3666

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

Upvotes: 2

Related Questions