Set <item name="android:fontFamily">@font/montserrat_regular</item> in styles.xml
<style name="NavigationView" >
<item name="android:fontFamily">@font/montserrat_regular</item>
</style>
Custom font is set in navigation drawer, but when selecting an item from the drawer, and after the drawer closes, when the drawer is reopened, the first 5 items from the top has resetted back to the system roboto font.
I have rearranged the list to rule out individual items, but it is always the first five. The custom font remains for the items below.
Expected behavior: The nav items font should always be the same
Source code: The code snippet which is causing this issue. Please consider attaching a minimal sample app that reproduces the issue.
Android API version: Android 10
Material Library version: com.google.android.material:material:1.2.0-alpha04
Device: Pixel 2
Same issue here. Any news on this?
Havent heard anything, and this issue hasnt been updated.
Hopefully, some kind person will fix this soon.
No news so far?. It is really annoying to see how badly it looks when I open my navigation drawer. Could somebody point us to a possible solution or workaround? Anything?
Thanks!
Does your custom font load after a short wait or is it forever reset back to Roboto?
My custom font appears sometimes but as soon as I click on a drawer item it goes back to roboto. And that's not always the case, sometimes only the roboto font is shown.
Found a solution:
Make sure NavigationView DOES NOT use:
android:theme="@style/MyCustomNavStyle"
but use:
app:itemTextAppearance="@style/MyCustomNavStyle"
<style name="MyCustomNavStyle">
<item name="android:fontFamily">@font/montserrat_regular</item>
</style>
Seems to have fixed it
Unbelievable! It works @johnnyzen, thank you!
@johnnyzen Unbelievable! It works!!!!!!! In 1.3.0-alpha02 still broken
I'm facing the same issue. I'm using Jetpack navigation component and because I wanted custom widgets in drawer menu, I ended up writing nested NavigationViews:
<com.google.android.material.navigation.NavigationView
...>
<androidx.constraintlayout.widget.ConstraintLayout
...>
<com.google.android.material.navigation.NavigationView
app:menu="@menu/menu_main"
...>
<!-- some other views -->
(I'm not setting any theme stuff on NavigationViews.)
On loading views, navigation drawer custom font is OK. The interesting part is when I click on my custom widgets, everything remains OK, but when I click on menu items handled with navigation component and NavigationUI, the whole font of outer NavigationView resets to default. (If I go to another page and get back to main screen, font is OK again)
I set font family in application theme:
<style name="Base.Theme.OfflineTools" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="fontFamily">@font/iransans</item>
<item name="android:fontFamily">@font/iransans</item>
</style>
Material v1.2.1 and Navigation Component v2.3.2
Most helpful comment
Unbelievable! It works @johnnyzen, thank you!