How to change position of Alert Dialog

2019-05-23 00:08发布

问题:

I have an android application uses Alertdialog.I am setting animation for this dialog.I want to start the animation from top left and ends at bottom right.ie,The dialog want to moves from top-left to bottom-right with in the animation duration time.

How can i achieve this?

回答1:

try this

AlertDialog.Builder alert = new AlertDialog.Builder(this);
        alert.setTitle("Final Result");
        alert.setMessage(msg);
        alert.setPositiveButton("OK",
                new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        // TODO Auto-generated method stub

                    }

                });


        // dlgAlert.create();
        AlertDialog dialog_card = alert.create();
        // dlgAlert.requestWindowFeature(Window.FEATURE_NO_TITLE);
        // WindowManager.LayoutParams WMLP =
        dialog_card.getWindow().setGravity(Gravity.TOP);

        dialog_card.show();`