我想改变抽屉导航的汉堡/箭头图标的颜色。我知道我可以在样式中更改它,但我想在 java 中动态更改它。有人知道怎么做吗?
最佳答案
使用 appcompat-v7:23.0.1 下一个代码对我有用:
int color = Color.parseColor("#FFEEEE00");
final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP);
for (int i = 0; i < toolbar.getChildCount(); i++) {
final View v = toolbar.getChildAt(i);
if (v instanceof ImageButton) {
((ImageButton) v).setColorFilter(colorFilter);
}
}
在 public boolean onCreateOptionsMenu(Menu menu)
中使用它
关于java - Android 汉堡/箭头图标动态改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32228199/