Navigation Drawer Menu Item Title Color in Android
Just add app:itemTextColor="@color/accent
property in your Navigation view tag like below.
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:backgroundTint="@color/primary"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer"
app:itemTextColor="@color/accent"/>
You can also define new style in styles.xml:
<style name="NavigationView">
<item name="android:textColorSecondary">@color/white</item>
</style>
and then applying this style in NavigationView's theme:
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:theme="@style/NavigationView" />
To give Menu
item title
color
and textSize
Create this way..
add this to your styles.xml
file.
<style name="TextAppearance44">
<item name="android:textColor">#FF0000</item>
<item name="android:textSize">20sp</item>
</style>
now in activity_main_drawer.xml
file give id
attribute
to title
..
<item android:title="Tools"
android:id="@+id/tools">
<menu>
<item
android:id="@+id/nav_settings"
android:icon="@mipmap/settings"
android:title="Settings" />
<item
android:id="@+id/nav_help"
android:icon="@mipmap/information"
android:title="Help" />
<item
android:id="@+id/nav_about"
android:icon="@mipmap/team"
android:title="About Us" />
</menu>
</item>
now In MainActivity.java
file use this way..
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
Menu menu = navigationView.getMenu();
MenuItem tools= menu.findItem(R.id.tools);
SpannableString s = new SpannableString(tools.getTitle());
s.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance44), 0, s.length(), 0);
tools.setTitle(s);
navigationView.setNavigationItemSelectedListener(this);
It will change your tools
color
to Red
and TextSize
to 20sp
.. Implement it..
In my case Output :