Calligraphy: Calligraphy does not work with NavigationView
I tried to change it using Calligraphy configs but didn’t work
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf")
.setFontAttrId(R.attr.fontPath)
.build());
Also, I tried to get the menu from the NavigationView navigationView.getMenu() and use CalligraphyTypefaceSpan to set the title with no luck!
Is there anyway to achieve that?
Thanks in advance
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 4
- Comments: 21 (7 by maintainers)
I ended-up hacking the drawer menu to force the font when the
DrawerStateChanged: See the source code here:https://gist.github.com/jzeferino/797c5e6b72c666b6f87969f6146a2a6e
@jzeferino Great tip! But, i realized that when the activity is resumed or when configuration changes, it uses the default font. In that case, it work when close and reopen the navigationview (eg. when the app is restarted or something related to configuration change while nav-view its opened).
Finally, i ended up using this approach:
(1) in strings.xml:
(2) in activity_home.xml:
Taken from here
I have custom font with calligraphy working a-ok with
<android.support.design.widget.NavigationView />I wonder if there’s an issue withapp:itemTextAppearance="@style/AppTheme.NavigationView"? I am not using that, insteadapp:itemTextColor="@color/textColorBright". I’ve found with other android.support.design views the TextAppearance screws things up.I think the
NavigationViewisn’t a textview. and doesn’t inflate it’s children.Need to nudge Goog to make there support lib stuff use the LayoutInflater.