The navbar icon icon changes color
I want to change the color of the navigation drawer icon (3 vertical stripes) from white to gray. How to do it in the simplest way?
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/grey"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Toolbar Title"
android:id="@+id/toolbar_title"
android:textColor="#010101" />
<!--android:layout_gravity="center"-->
</android.support.v7.widget.Toolbar>
+3
source to share
3 answers
Get available
Drawable icMenu = ContextCompat.getDrawable (this, R.drawable.ic_hamburguer);
Shade
icMenu.setColorFilter (GetResources (). GetColor (android.R.color.darker_gray), PorterDuff.Mode.SRC_ATOP);
Use it with actionBar
actionBar.setHomeAsUpIndicator (icMenu);
actionBar.setDisplayHomeAsUpEnabled (true);
Or toolbar
toolbar.setNavigationIcon (icMenu);
+2
source to share
Change toolbar theme
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/grey"
local:theme="@style/CustomTheme"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Toolbar Title"
android:id="@+id/toolbar_title"
android:textColor="#010101" />
<!--android:layout_gravity="center"-->
</android.support.v7.widget.Toolbar>
And in your styles.xml
Create a new style like this.
<style name="CustomTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColorPrimary">#COLOR_CODE_FOR_YOUR_TEXT</item>
<item name="android:textColorSecondary">#COLOR_CODE_FOR_YOUR_TOOLBAR_ICON</item>
</style>
+1
source to share