I\'m using CoordinatorLayout in my project . It works fine but there is a problem I need to fix .I\'m using white actionbar icons and When the CoordinatorLayout is expanded and
You can do this similar to as shown in this Stack Overflow post. Thanks to tachyonflux
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
AppBarLayout appBar = (AppBarLayout) findViewById(R.id.appbar);
appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if ((collapsingToolbar.getHeight() + verticalOffset) < (2 * ViewCompat.getMinimumHeight(collapsingToolbar))) {
toolbar.getNavigationIcon().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);
} else {
toolbar.getNavigationIcon().setColorFilter(getResources().getColor(R.color.black), PorterDuff.Mode.SRC_ATOP);
}
}
});
Similarly you can apply it for any drawable or images within toolbar or collapsing toolbar layout.