To display the required dialog box top right of the screen use this code :
Window window = alertdialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.TOP | Gravity.RIGHT;
wlp.width = ViewGroup.LayoutParams.MATCH_PARENT;
wlp.y=100 ; //if you want give margin from top
//wlp.x=100 ; //if you want give margin from left
wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(wlp);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.