question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[NavigationView] Custom Font resetting back to Roboto (system default) on item click

See original GitHub issue

Set <item name="android:fontFamily">@font/montserrat_regular</item> in styles.xml

  • In either main apptheme or

<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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
johnnyzencommented, Jul 15, 2020

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

5reactions
j3susalonsocommented, Jul 15, 2020

Unbelievable! It works @johnnyzen, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set custom typeface to items in NavigationView?
We're going to have to supply each MenuItem with a unique id and this callback will help generify those ids as much as...
Read more >
Bottom navigation - Material Design
Bottom navigation bars allow movement between primary destinations in an app.
Read more >
Roboto - Google Fonts
Google Fonts: Roboto​​ Roboto has a dual nature. It has a mechanical skeleton and the forms are largely geometric. At the same time,...
Read more >
Typography - Material UI - MUI
You can change the font family with the theme.typography.fontFamily property. For instance, this example uses the system font instead of the default Roboto...
Read more >
Navigation bar title style, color and custom back button in SwiftUI
To change the color of the navigation bar and the title text, we can use UINavigationBarAppearance, which is available since iOS 13. We...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found