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>
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 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 the Text color of collapsing toolbar and the back button color of collapsing toolbar in android
The CollapsingToolBar that is in the Android Design lib will do what you are asking.
You will need to apply a custom toolbar theme. Here is an example (this IS your styles.xml file).
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="CustomToolbarTheme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<!-- HERE ARE THE CHANGES - Change color of different texts -->
<item name="android:textColorPrimary">@color/wacky_blue</item>
<item name="colorControlNormal">@color/toolbar_color</item>
</style>
</resources>
then you will need to set this on your App Bar:
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
...
android:theme="@style/CustomToolbarTheme"
...>
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>
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"/>
Changing Toolbar text color
You can do like this
private void setToolbar(){
toolbar = (Toolbar)findViewById(R.id.toolbar);
toolbar.setTitleTextColor(ContextCompat.getColor(getApplicationContext(),R.color.yellow));
setSupportActionBar(toolbar);
}
Related Topics
Compatiblity of Material Design to Versions Below Android 5.0
Scrolling Edittext Inside Scrollview
Ask for Password Before Uninstalling Application
Extracting Information from a Scanned Gs1-Type Barcode
Cannot Resolve Mapactivity Class on Android
Android Marshmallow: Changing Permissions at Run Time Crashes App
How to Create and Save a Screenshot from a Surfaceview
Android Spinner Error:Android.View.Windowmanager$Badtokenexception: Unable to Add Window
Ndk: How Include *.So Files in Androidstudio
Why Does Navigation Not Work in the Navigation Drawer Activity Template with Version 2.4.1
How to Animate a Slide in Notification View That Pushes the Content View Down
Sdcard Content Exist But Cant See Them
Multiple Dex Files Define Lcom/Google/Android/Gms/Internal/Zzau
How to Disable Proguard for Building My Android App
Which View Should Be Used for New Material Design Bottom Navigation