Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onViewCreated(final View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- // This is done in a post() since the dialog must be drawn before locating.
- getView().post(new Runnable() {
- @Override
- public void run() {
- Window dialogWindow = getDialog().getWindow();
- // Make the dialog possible to be outside touch
- dialogWindow.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
- WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
- dialogWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
- getView().invalidate();
- }
- });
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Hide title of the dialog
- setStyle(STYLE_NO_FRAME, 0);
- }
- window.setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
- WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
- @Override
- public void onStart() {
- // mDialogView is member variable
- mDialogView = getView();
- mDialogView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- float eventX = event.getRawX();
- float eventY = event.getRawY();
- int location[] = new int[2];
- mDialogView.getLocationOnScreen(location);
- if (eventX < location[0] || eventX > (location[0] + mDialogView.getWidth()) || eventY < location[1]
- || eventY > location[1] + mDialogView.getHeight()) {
- dismiss();
- return true;
- }
- return false;
- }
- });
- }
- FragmentTransaction transaction = fragmentManager.beginTransaction();
- // For a little polish, specify a transition animation
- transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
- // To make it fullscreen, use the 'content' root view as the container
- // for the fragment, which is always the root view for the activity
- transaction.add(android.R.id.content, newFragment)
- .addToBackStack(null).commit();
- @NonNull
- @Override
- public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) {
- final Dialog dialog = super.onCreateDialog(savedInstanceState);
- dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
- return dialog;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement