android - button visibility on bottom sheet behavior change -
i have button called share on bottomsheet ,now want button visible if state expanded , in other state button should not visible. here code have tried.
if (mbottomsheetbehavior.getstate() == bottomsheetbehavior.state_expanded) {share.setvisibility(view.visible);} if(mbottomsheetbehavior.getstate()==bottomsheetbehavior.state_collapsed){share.setvisibility(view.gone);} if(mbottomsheetbehavior.getstate()==bottomsheetbehavior.state_settling){share.setvisibility(view.gone);} if(mbottomsheetbehavior.getstate()==bottomsheetbehavior.state_settling){share.setvisibility(view.gone);}
but when drag bottomsheet expand or collapse nothing happens , there correct way don't know
you can try this
mbottomsheetbehavior.setbottomsheetcallback(new bottomsheetbehavior.bottomsheetcallback() { @override public void onstatechanged(view bottomsheet, int newstate) { if (newstate == bottomsheetbehavior.state_expanded) { share.setvisibility(view.visible); }else{ share.setvisibility(view.gone); } } @override public void onslide(view bottomsheet, float slideoffset) { } });
Comments
Post a Comment