android BottomSheet how to collapse when clicked outside?
问题 I have implemented bottomsheet behavior with NestedScrollView. And was wondering if it is possible to hide the bottomsheet view when touched outside. 回答1: Finally I was able to do this, Used the 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