You can define a custom font for your application with Calligraphy (https://github.com/chrisjenx/Calligraphy)
Add the dependency in your build.gradle :
dependencies {
...
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
...
}
Add Fonts
Add your custom fonts to a assets/fonts/
folder
Installation, setup default font for your entire app
Define your default font using CalligraphyConfig, in your Application class in the #onCreate() method.
@Override
public void onCreate() {
super.onCreate();
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf")
.setFontAttrId(R.attr.fontPath)
.build()
);
//....
}
Note: You don't need to define CalligraphyConfig but the library will apply no default font and use the default attribute of R.id.fontPath.
In every Activity :
Do this in every Activity
of your App where you want the new font:
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
You're good to go!