How To Set The Toolbar Collapseicon Color Programmatically
I want to change the color of the back button in the toolbar when a search is displayed (the circled white arrow). I managed to change the color of all other elements and I am st
Solution 1:
Finally got it...
This is what worked for me:
finalToolbartoolbar= (Toolbar) findViewById(R.id.toolbar);
AppBarLayoutappBar= (AppBarLayout) findViewById(R.id.appbar);
appBar.addOnOffsetChangedListener(newAppBarLayout.OnOffsetChangedListener() {
@OverridepublicvoidonOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
for (inti=0; i < toolbar.getChildCount(); i++) {
Viewview= toolbar.getChildAt(i);
if (view instanceof ImageButton) {
ImageButtonbtn= (ImageButton) view;
Drawabledrawable= btn.getDrawable();
drawable.setColorFilter(new_button_color, PorterDuff.Mode.SRC_ATOP);
btn.setImageDrawable(drawable);
}
}
}
});
Post a Comment for "How To Set The Toolbar Collapseicon Color Programmatically"