public BottomSheetDialog canceledOnTouchOutside(boolean cancel){ super.setCanceledOnTouchOutside(cancel); mCanceledOnTouchOutside = cancel; return this; }
/** * Sets whether this dialog is canceled when touched outside the window's * bounds. If setting to true, the dialog is set to be cancelable if not * already set. * * @param cancel Whether the dialog should be canceled when touched outside * @return The Dialog for chaining methods. */ public Dialog canceledOnTouchOutside(boolean cancel){ super.setCanceledOnTouchOutside(cancel); mCanceledOnTouchOutside = cancel; return this; }
public void setCanceledOnTouchOutside(boolean flag) { dialog.setCanceledOnTouchOutside(flag); }
Dialog dialog = new Dialog(context) dialog.setCanceledOnTouchOutside(true);
@Override public void setCanceledOnTouchOutside(boolean cancel) { this.mCancel = cancel; super.setCanceledOnTouchOutside(cancel); }
public static Dialog showDialogForLoading(Activity context) { View view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null); TextView loadingText = (TextView)view.findViewById(R.id.id_tv_loading_dialog_text); loadingText.setText("加载中..."); mLoadingDialog = new Dialog(context, R.style.CustomProgressDialog); mLoadingDialog.setCancelable(true); mLoadingDialog.setCanceledOnTouchOutside(false); mLoadingDialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); mLoadingDialog.show(); return mLoadingDialog; }
@Implementation protected void setCanceledOnTouchOutside(boolean flag) { isCancelableOnTouchOutside = flag; directlyOn(realDialog, Dialog.class).setCanceledOnTouchOutside(flag); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.65); int dialogWidth = (int) (mContext.getResources().getDisplayMetrics().widthPixels * 0.77); getDialog().getWindow().setLayout(dialogWidth, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.71); int dialogWidth = (int) (mContext.getResources().getDisplayMetrics().widthPixels * 0.79); getDialog().getWindow().setLayout(dialogWidth, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }
public MDSelectionDialog(Builder builder) { this.mBuilder = builder; mDialog = new Dialog(mContext, R.style.MyDialogStyle); dialogView = View.inflate(mContext, R.layout.widget_md_mid_dialog, null); linearLayout = (LinearLayout) dialogView.findViewById(R.id.md_mid_dialog_linear); mDialog.setContentView(dialogView); // 一定要在setAttributes(lp)之前才有效 //设置dialog的宽 Window dialogWindow = mDialog.getWindow(); WindowManager.LayoutParams lp = dialogWindow.getAttributes(); lp.width = (int) (ScreenSizeUtils.getInstance(mContext).getScreenWidth() * builder.itemWidth); lp.gravity = Gravity.CENTER; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; dialogWindow.setAttributes(lp); mDialog.setCanceledOnTouchOutside(builder.isTouchOutside()); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.30); getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * heightPercent); ; // WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); // Display display = wm.getDefaultDisplay(); // int height = display.getHeight(); getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * heightPercent); ; // WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); // Display display = wm.getDefaultDisplay(); // int height = display.getHeight(); getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * heightPercent); ; // WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); // Display display = wm.getDefaultDisplay(); // int height = display.getHeight(); getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.6); getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels * 0.65); int dialogWidth = (int) (getActivity().getResources().getDisplayMetrics().widthPixels * 0.77); getDialog().getWindow().setLayout(dialogWidth, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels); int dialogWidth = (int) (getActivity().getResources().getDisplayMetrics().widthPixels); getDialog().getWindow().setLayout(dialogWidth, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }
private void initDialog() { contentLayout = new FrameLayout(activity); contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); contentLayout.setFocusable(true); contentLayout.setFocusableInTouchMode(true); dialog = new Dialog(activity); dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体 dialog.setCancelable(true);//按返回键取消窗体 dialog.setOnKeyListener(this); dialog.setOnDismissListener(this); Window window = dialog.getWindow(); if (window != null) { window.setGravity(Gravity.BOTTOM); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //AndroidRuntimeException: requestFeature() must be called before adding content window.requestFeature(Window.FEATURE_NO_TITLE); window.setContentView(contentLayout); } setSize(screenWidthPixels, WRAP_CONTENT); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels * 0.56); int dialogWidth = (int) (getActivity().getResources().getDisplayMetrics().widthPixels * 0.63); getDialog().getWindow().setLayout(dialogWidth, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }
@Override public void onStart() { super.onStart(); //设置fragment高度 、宽度 int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels); int dialogWidth = (int) (getActivity().getResources().getDisplayMetrics().widthPixels); getDialog().getWindow().setLayout(dialogWidth, dialogHeight); getDialog().setCanceledOnTouchOutside(true); }