[英]Android studio navigation drawer icon color
All my fragments use red action bar, so white navigation drawer icon looks good. 我所有的片段都使用红色的操作栏,因此白色的导航抽屉图标看起来不错。 But for one fragment I need white action bar and drawer icon not visible.
但是对于一个片段,我需要白色的操作栏和抽屉图标不可见。 So I have to change drawer icon to red.
因此,我必须将抽屉图标更改为红色。 But I can't find how to do this.
但是我找不到如何做到这一点。
Create style like this for your required activity styles.xml
为所需的活动
styles.xml
创建这样的样式
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">@color/red</item>
</style>
And then add it to you Activity theme like this: 然后将其添加到活动主题中,如下所示:
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
Hope this helps,as it worked for me. 希望这对我有所帮助,对您有所帮助。
Drawable myDrawable = context.getResources().getDrawable(R.drawable.menu);
mDrawable.setColorFilter(new
PorterDuffColorFilter(0xffff00,PorterDuff.Mode.MULTIPLY));
Been trying to do this myself and through trial and error came up with the following 一直尝试自己做,并通过反复试验得出以下结论
drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
toggle = new ActionBarDrawerToggle(MainActivity.this, drawerLayout, R.string.open, R.string.close);
int color = getResources().getColor(getResources().getIdentifier("red", "color", getPackageName()));
toggle.getDrawerArrowDrawable().setColor(color);
I prefer this method personally as you can replace "red" with a variable which suited my needs perfectly 我个人更喜欢这种方法,因为您可以用完全适合我需要的变量替换“红色”
Just follow the instructions from either of these links. 只需按照以下两个链接中的说明进行操作即可。 Your Problem will be solved.
您的问题将得到解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.