AndroidDev
AndroidDev

Reputation: 16385

Android: set application-wide font

I have to use custom fonts in my application. I know how to read a font from the assets directory and apply them to a control, however this seems a very laborious task.

Is there anyway I can apply a custom font from my assets directory to all the controls in the application.

Upvotes: 0

Views: 225

Answers (2)

harshit
harshit

Reputation: 3846

One thing you can do is: Make custom textViews, by extending them, and then use them in your xml layouts. You will have to override setTypeface(Typeface tf, int style) method for that. You may want to have a look at this

Upvotes: 1

user948620
user948620

Reputation:

Try this

If from your asset folder

Typeface.createFromAsset(yourAssetManager, pathOfYourFontAsset);

If externally

Typeface.createFromFile(path)

Upvotes: 0

Related Questions