设置DrawerLayout关联toolbar的按钮的颜色

 

就是这家伙的三道杠的颜色。


默认情况下你应该使用的是style.xml中的AppTheme主题(这个可以在AndroidManifest.xml中看出来)。假设是这样,那么你可以通过以下方法改变 drawer 按钮的颜色:

  1. 进入style.xml

  2. 增加一种继承自Widget.AppCompat.DrawerArrowToggle的style,这里叫做"DrawerArrowStyle"。在里面加上你想要的颜色,这里比如@color/colorBlue

  3. 在 style "AppTheme" 中增加一行名为 drawerArrowStyle 的这种 style。

这样一来,style 中便有如下两项:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="color">@color/colorBlue</item>
</style>

再运行你就看到结果了。


猜你喜欢

转载自blog.csdn.net/lyc088456/article/details/80106685
今日推荐