How to change color of the back arrow in the new material theme?
You can achieve it through code. Obtain the back arrow drawable, modify its color with a filter, and set it as back button.
final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(getResources().getColor(R.color.grey), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);
Revision 1:
Starting from API 23 (Marshmallow) the drawable resource abc_ic_ab_back_mtrl_am_alpha
is changed to abc_ic_ab_back_material
.
EDIT:
You can use this code to achieve the results you want:
toolbar.getNavigationIcon().setColorFilter(getResources().getColor(R.color.blue_gray_15), PorterDuff.Mode.SRC_ATOP);
How to change Toolbar home icon(back arrow) color in new material theme?
Very simple, this worked for me:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/PrimaryColor"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="4dp" />
How to change color of Toolbar back button in Android?
use this style
<style name="Theme.MyFancyTheme" parent="android:Theme.Holo">
<item name="android:homeAsUpIndicator">@drawable/back_button_image</item>
</style>
Change toolbar back arrow color
You can override the theme in your Toolbar
.
With a Material Components theme:
<com.google.android.material.appbar.MaterialToolbar
style="@style/Widget.MaterialComponents.Toolbar.Primary"
android:theme="@style/MyThemeOverlay_Toolbar"
..>
with:
<style name="MyThemeOverlay_Toolbar2" parent="ThemeOverlay.MaterialComponents.Toolbar.Primary">
<!-- This attributes is used by navigation icon and overflow icon -->
<item name="colorOnPrimary">@color/secondaryColor</item>
</style>
With an AppCompat theme:
<android.support.v7.widget.Toolbar
android:theme="@style/myToolbarTheme"
...
>
Then in your theme you can define the colorControlNormal
attribute:
<style name="" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
....
<item name="colorControlNormal">@color/myColor</item>
</style>
How to change the appBar back button color
You have to use the iconTheme
property from the AppBar , like this:
appBar: AppBar(
iconTheme: IconThemeData(
color: Colors.black, //change your color here
),
title: Text("Sample"),
centerTitle: true,
),
Or if you want to handle the back button by yourself.
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
),
title: Text("Sample"),
centerTitle: true,
),
Even better, only if you want to change the color of the back button.
appBar: AppBar(
leading: BackButton(
color: Colors.black
),
title: Text("Sample"),
centerTitle: true,
),
Change back icon color in toolbar
use this style
<style name="ToolbarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">
<!-- Customize color of Toolbar -->
<item name="colorControlNormal">@color/WhiteColor</item>
</style>
and then use it in app:theme="@style/ToolbarTheme"
in your Toolbar XML :
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:textColor="#FFF"
android:textColorPrimary="#FFF"
app:theme="@style/ToolbarTheme"
app:layout_constraintTop_toTopOf="parent"
app:titleTextColor="#FFF"
app:title="@string/app_name"/>
Related Topics
Why I Cant Use the Populateviewholder Override Method
Running Java Program from Command Line Linux
Spring JSON Request Getting 406 (Not Acceptable)
Upload Files from Java Client to a Http Server
What Is the Maximum Depth of the Java Call Stack
Who Sets Response Content-Type in Spring MVC (@Responsebody)
How to Convert Object Array to String Array in Java
How to "Intercept" Ctrl+C in a Cli Application
Key Bindings VS. Key Listeners in Java
JSONparser from Androidhive Tutorial, Nosuchmethoderror in Defaulthttpclient
What Is the Jasperrepots-Fonts Jar for and How to Use It
How to Click an Element in Selenium Webdriver Using JavaScript
JPA Cascadetype.All Does Not Delete Orphans
How to Instantiate an Inner Class with Reflection in Java