How to change color of Toolbar back button in Android?

后端 未结 17 1115
不知归路
不知归路 2020-12-04 06:51

I could not change the color of back button. I am using toolbar material design. In my app I am applying black background of tool bar but the back design is being black by d

相关标签:
17条回答
  • 2020-12-04 07:36

    Use this:

    <style name="BaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
      <item name="colorControlNormal">@color/white</item> 
    </style>
    
    0 讨论(0)
  • 2020-12-04 07:37

    Here is the simplest way of achieving Light and Dark Theme for Toolbar.You have to change the value of app:theme of the Toolbar tag

    • For Black Toolbar Title and Black Up arrow, your toolbar should implement following theme:

    app:theme="@style/ThemeOverlay.AppCompat.Light"

    • For White Toolbar Title and White Up arrow, your toolbar should implement following theme:

    app:theme="@style/ThemeOverlay.AppCompat"

    0 讨论(0)
  • 2020-12-04 07:38

    I am using <style name="BaseTheme" parent="Theme.AppCompat.Light.NoActionBar> theme in my android application and in NoActionBar theme, colorControlNormal property is used to change the color of navigation icon default Back button arrow in my toolbar

    styles.xml

    <style name="BaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
      <item name="colorControlNormal">@color/your_color</item> 
    </style>
    
    0 讨论(0)
  • 2020-12-04 07:39

    To style the Toolbar on Android 21+ it's a bit different.

    <style name="DarkTheme.v21" parent="DarkTheme.v19">
            <!-- toolbar background color -->
            <item name="android:navigationBarColor">@color/color_primary_blue_dark</item>
            <!-- toolbar back button color -->
            <item name="toolbarNavigationButtonStyle">@style/Toolbar.Button.Navigation.Tinted</item>
        </style>
    
        <style name="Toolbar.Button.Navigation.Tinted" parent="Widget.AppCompat.Toolbar.Button.Navigation">
            <item name="tint">@color/color_white</item>
        </style>
    
    0 讨论(0)
  • 2020-12-04 07:41

    You don't have to change style for it. After setting up your toolbar as actionbar, You can code like this

    android.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    android.getSupportActionBar().setHomeAsUpIndicator(R.drawable.back);
    //here back is your drawable image
    

    But You cannot change color of back arrow by this method

    0 讨论(0)
提交回复
热议问题