Search code examples
androidmaterial-designnavigation-drawermaterial-components-android

Why the texts inside the navigation drawer are not the same?


Can I know why the texts inside the navigation drawer are not the same?

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".activities.MainActivity"
    tools:openDrawer="start">
    
    ...

    <com.google.android.material.navigation.NavigationView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:menu="@menu/menu_navigation_drawer" />

</androidx.drawerlayout.widget.DrawerLayout>

----------

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:title="Other">
        <menu>
            <item
                android:icon="@drawable/ic_star"
                android:title="Rate the app" />

            <item
                android:icon="@drawable/ic_share"
                android:title="Share the app" />

            <item
                android:icon="@drawable/ic_shield"
                android:title="Privacy policy" />

            <item
                android:icon="@drawable/ic_document"
                android:title="Terms of services" />
        </menu>
    </item>
</menu>

Notice some items have bold texts and some items have regular texts.

Why is that happening?

I'm using Material Design 3.


Solution

  • The solution

    <style name="styleName" parent="TextAppearance.Material3.LabelLarge">
        <item name="fontFamily">@font/font_regular</item>
    </style>
    

    Then add this inside NavigationView

    app:itemTextAppearance="@style/styleName"