bottom sheet - android BottomSheet how to collapse when clicked outside? -
i have implemented bottomsheet behavior nestedscrollview. , wondering if possible hide bottomsheet view when touched outside.
finally able this,
used following lines of code:
@override public boolean dispatchtouchevent(motionevent event){ if (event.getaction() == motionevent.action_down) { if (mbottomsheetbehavior.getstate()==bottomsheetbehavior.state_expanded) { rect outrect = new rect(); bottomsheet.getglobalvisiblerect(outrect); if(!outrect.contains((int)event.getrawx(), (int)event.getrawy())) mbottomsheetbehavior.setstate(bottomsheetbehavior.state_collapsed); } } return super.dispatchtouchevent(event); }
Comments
Post a Comment