Guest User

Untitled

a guest
Jan 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. @Override
  2. public Dialog onCreateDialog(Bundle savedInstanceState) {
  3. final Dialog d = super.onCreateDialog(savedInstanceState);
  4. // view hierarchy is inflated after dialog is shown
  5. d.setOnShowListener(new DialogInterface.OnShowListener() {
  6. @Override
  7. public void onShow(DialogInterface dialogInterface) {
  8. //this disables outside touch
  9. d.getWindow().findViewById(R.id.touch_outside).setOnClickListener(null);
  10. //this prevents dragging behavior
  11. View content = d.getWindow().findViewById(R.id.design_bottom_sheet);
  12. ((CoordinatorLayout.LayoutParams) content.getLayoutParams()).setBehavior(null);
  13. }
  14. });
  15. return d;
  16. }
  17.  
  18. override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
  19. val d = super.onCreateDialog(savedInstanceState)
  20. //view hierarchy is inflated after dialog is shown
  21. d.setOnShowListener {
  22. //this disables outside touch
  23. d.window.findViewById<View>(R.id.touch_outside).setOnClickListener(null)
  24. //this prevents dragging behavior
  25. (d.window.findViewById<View>(R.id.design_bottom_sheet).layoutParams as CoordinatorLayout.LayoutParams).behavior = null
  26. }
  27. return d
  28. }
Add Comment
Please, Sign In to add comment