Dialog 팝업 상자(보통 가운데에서 팝업 및 아래쪽 애니메이션에서 팝업)

private CustomDialog mDialogEdit;
    private TextView mTvTitle;
    private TextView mTvCancel;
    private TextView mTvOK;
    private void showEditDialog(AcademiaPersonBean personBean) {
        if (mDialogEdit == null) {
            mDialogEdit = new CustomDialog(mContext, R.style.style_dialog_add_pic);
            View contentView = View.inflate(mContext, R.layout.dialog_edit_reason, null);
            mDialogEdit.setContentView(contentView);
            mTvCancel=contentView.findViewById(R.id.tv_cancel_edit_dialog);
            mTvOK=contentView.findViewById(R.id.tv_ok_edit_dialog);
            mTvTitle=contentView.findViewById(R.id.tv_title_edit_dialog);

            Window window = mDialogEdit.getWindow();
//        window.setGravity(Gravity.BOTTOM);
//        WindowManager.LayoutParams layoutParams=new WindowManager.LayoutParams();// style 
            WindowManager.LayoutParams layoutParams = window.getAttributes();
            layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
            layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
//            layoutParams.dimAmount = 0.3f;
            layoutParams.gravity = Gravity.CENTER;//BOTTOM
            window.setAttributes(layoutParams);
//            window.setWindowAnimations(R.style.dialog_anim);// 
            mDialogEdit.setCanceledOnTouchOutside(true);
        }
        mTvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mDialogEdit.dismiss();
            }
        });
        mTvOK.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mDialogEdit.dismiss();
            }
        });
        String titleText=String.format(getMyString(R.string.text_forbid_talk_5_somebody),"\""+personBean.personName+"\"");
        mTvTitle.setText(titleText);
        mDialogEdit.show();
    }

 

좋은 웹페이지 즐겨찾기