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

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -