2

I'm trying to change the font of my navigation drawer's items but its not working. I'm setting it to a specific theme/style, the Material Design Button text. I've got it working for the Toolbar (Actionbar) but I can't seem to change the navigation drawer's items' text at all.

I'm trying to set this: NavDrawer [NavDrawer]

into this font/style: Toolbar Style

[Toolbar Style].

I've tried changing the "app" attributes in the NavigationView but it doesn't work for me. Here's my layout.xml and my styles.xml.

Any help or suggestions are welcome, Thanks!

Layout.xml:

    <android.support.design.widget.CoordinatorLayout>

    <LinearLayout>
        <android.support.v7.widget.Toolbar
            android:id="@+id/fragment_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@android:color/transparent"
       android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light"
            app:titleTextAppearance="@style/TextAppearance.AppTheme.Toolbar">
        </android.support.v7.widget.Toolbar>
    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    style="@style/Widget.MaterialComponents.NavigationView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@color/themePrimaryLight"
    app:elevation="8dp"
    app:headerLayout="@layout/nav_header"
    app:itemIconPadding="60dp"
    app:itemIconTint="@color/colorSecondLight"
    app:itemTextAppearance="@font/rubik_regular"
    app:itemTextColor="@color/colorSecondLight"
    app:menu="@menu/nav_drawer_base" />

</android.support.v4.widget.DrawerLayout>

Styles.xml:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorSecondDark</item>

    <item name="android:statusBarColor">@color/fullAlpha</item>
</style>

<style name="AppThemeActionBar" parent="Theme.MaterialComponents.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorSecondDark</item>
</style>

<style name="Widget.AppTheme.Toolbar" parent="Widget.AppCompat.Toolbar">
    <item name="titleTextAppearance">@style/TextAppearance.AppTheme.Toolbar</item>
</style>

<style name="TextAppearance.AppTheme.Toolbar" parent="TextAppearance.MaterialComponents.Button">
    <item name="android:textSize">16sp</item>
</style>


<style name="NavigationDrawerStyle">
    <item name="android:textSize">14sp</item>
    <item name="android:itemTextAppearance">@style/TextAppearance.AppTheme.Toolbar</item>
</style>


</resources>
karthik
  • 528
  • 4
  • 19
Varun Govind
  • 983
  • 2
  • 12
  • 23
  • 1
    See this [https://stackoverflow.com/questions/30668346/how-to-set-custom-typeface-to-items-in-navigationview](https://stackoverflow.com/questions/30668346/how-to-set-custom-typeface-to-items-in-navigationview) – Fidz Aug 21 '18 at 00:53
  • @MochammadHafidz, I've got it working from this post: https://stackoverflow.com/questions/34611619/how-to-change-navigation-drawer-font, but now my checkable items aren't working. Would you know anything about it? Thanks. – Varun Govind Aug 21 '18 at 01:16
  • nvm, I got it, thanks for the suggestion! – Varun Govind Aug 21 '18 at 01:26

0 Answers0