Created
October 6, 2016 07:02
-
-
Save beta/c0f2a077773aaee329dadc3cbee8810c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void setCancelable(boolean cancelable) { | |
final Dialog dialog = getDialog(); | |
View touchOutsideView = dialog.getWindow().getDecorView().findViewById(android.support.design.R.id.touch_outside); | |
View bottomSheetView = dialog.getWindow().getDecorView().findViewById(android.support.design.R.id.design_bottom_sheet); | |
if (cancelable) { | |
touchOutsideView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
if (dialog.isShowing()) { | |
dialog.cancel(); | |
} | |
} | |
}); | |
BottomSheetBehavior.from(bottomSheetView).setHideable(true); | |
} else { | |
touchOutsideView.setOnClickListener(null); | |
BottomSheetBehavior.from(bottomSheetView).setHideable(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment