ActionBarDrawerToggle v7 arrow color

匿名 (未验证) 提交于 2019-12-03 02:15:02

问题:

When I try to change navigation drawer toggle color, only hamburger changes it, arrow keeps her native color. You can see it here -

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">     <item name="android:windowBackground">@drawable/app_background</item>     <item name="android:dropDownListViewStyle">@style/DropDownListViewStyle</item>     <item name="colorPrimary">@color/primary</item>     <item name="colorPrimaryDark">@color/primary_dark</item>     <item name="colorAccent">@color/accent</item>     <item name="android:textColor">@color/primary_text</item>     <item name="android:windowNoTitle">true</item>     <item name="windowActionBar">false</item>     <item name="drawerArrowStyle">@style/DrawerArrowStyle</item> </style>  <style name="DrawerArrowStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle">     <item name="spinBars">true</item>     <item name="color">@android:color/holo_red_dark</item> </style> 

If I change parent theme to Theme.AppCompat.Light arrow changes her color to black. The following widget are used: android.support.v7.app.ActionBarDrawerToggle; android.support.v7.widget.Toolbar;

What am I doing wrong?

回答1:

Try using

        <item name="colorControlNormal">@color/your_color</item>         <item name="android:colorControlNormal">@color/your_color</item> 

instead of your drawer arrow style.

To clear out my comment, try also:

    <item name="actionBarStyle">@style/My.ActionBar.Style</item> 

and then:

     <style name="My.ActionBar.Style" parent="Widget.AppCompat.ActionBar">          <item name="colorControlNormal">@color/your_color</item>         <item name="android:colorControlNormal">@color/your_color</item>      </style> 


回答2:

Try this one to change color of DrawerArrow

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">     <item name="spinBars">true</item>     <item name="color">@android:color/white</item> </style> 


回答3:

This worked for me:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {             mDrawerToggle.getDrawerArrowDrawable().setColor(getColor(R.color.drawer_toggle_color));         } else {             mDrawerToggle.getDrawerArrowDrawable().setColor(getResources().getColor(R.color.drawer_toggle_color));         } 


回答4:

You could set custom arrow or other icon using the method

toolbar.setNavigationIcon(Int drawable resource); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!