android - CollapsingToolbarLayout: Change home button color when expanded -
i have implemented new collapsingtoolbarlayout
chris banes example code.
however, images backdrop image view have white background. toolbar theme themeoverlay.appcompat.dark.actionbar
icons white too, can't see home button when collapsingtoolbarlayout expanded.
with app:expandedtitletextappearance
can set color title field. there possibility set color of home buttons , menu icons?
here example how change drawer , options icons color when layout expanded , collapsed:
protected void oncreate(bundle savedinstancestate) { appbarlayout appbarlayout = (appbarlayout) findviewbyid(r.id.app_bar_layout); appbarlayout.addonoffsetchangedlistener(new appbarlayout.onoffsetchangedlistener() { @override public void onoffsetchanged(appbarlayout appbarlayout, int offset) { drawable uparrow = resourcescompat.getdrawable(getresources(), r.drawable.drawer_icon, null); if (offset < -200) { uparrow.setcolorfilter(color.parsecolor("#000000"), porterduff.mode.src_atop); getsupportactionbar().sethomeasupindicator(uparrow); drawable drawable = contextcompat.getdrawable(getapplicationcontext(),r.drawable.option_menu_icon); drawable.setcolorfilter(color.parsecolor("#000000"), porterduff.mode.src_atop); toolbar.setoverflowicon(drawable); } else { uparrow.setcolorfilter(color.parsecolor("#ffffff"), porterduff.mode.src_atop); getsupportactionbar().sethomeasupindicator(uparrow); getsupportactionbar().setdisplayhomeasupenabled(true); drawable drawable = contextcompat.getdrawable(getapplicationcontext(),r.drawable.option_menu_icon); drawable.setcolorfilter(color.parsecolor("#ffffff"), porterduff.mode.src_atop); toolbar.setoverflowicon(drawable); } } });
Comments
Post a Comment