修改DrawerLayout 和toolbar 配合navigation的颜色

大家都知道DrawerLayout 和toolbar 结合能出来高大上的效果。 使用到一个ActionBarDrawerToggle类。


修改DrawerLayout 和toolbar 配合navigation的颜色_第1张图片




那么怎么修改DrawerToggle的颜色呢,搜索了很多中文网站都没有找到,果断求助stackoverflow


得到以下答案


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>

看来这个就是设置的地方了。。但是 这个style给谁呢
试了以下,原来是给你的NoActionBar的style加上
<style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    </style>

这样就可以改变颜色了,看来以后有问题 还要多去stackoverflow

另外 使用
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
得到的箭头怎么改呢。。
改图片资源
<style name="ToolbarStyle" parent="Widget.AppCompat.Toolbar"> <item name="navigationIcon">@drawable/ic_up_indicator</item> </style>



 或者加一个colorFilter
 final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
        upArrow.setColorFilter(Color.parseColor("#FFFFFF"), PorterDuff.Mode.SRC_ATOP);
        getSupportActionBar().setHomeAsUpIndicator(upArrow);



你可能感兴趣的:(android,toolbar)