How Do I Add Custom Font On Menu Item In Android?
I have been trying to add a font to my menu items and have tried few solutions i found but none of them worked for me. Method 1 :How to set custom typeface to items in NavigationVi
Solution 1:
you can use this lib https://github.com/chrisjenx/Calligraphy. It will set the default font to your menuItem when you attach it to a context
Solution 2:
There is a library https://github.com/chrisjenx/Calligraphy,
Add this dependency to your build gradle
dependencies {
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
}
Then in your activity override this method
@Override
public void onCreate() {
super.onCreate();
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf")
.setFontAttrId(R.attr.fontPath)
.build()
);
//....
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
Post a Comment for "How Do I Add Custom Font On Menu Item In Android?"