Reputation: 53
I want to change position of PopupWindow dynamically. Have used the following method:
public void showAtLocation (View parent, int gravity, int x, int y)
But sometime PopupWindow shows out of screen. So which relative parameter should I use for changing the value x and y (like layout height or width etc)?
Upvotes: 0
Views: 1932
Reputation: 73
You need to use
public void update(int x, int y, int width, int height)
metod in PopupWindow
Upvotes: 1
Reputation: 4487
Try this
AlertDialog dialog = builder.create();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
wmlp.gravity = Gravity.TOP | Gravity.LEFT;
wmlp.x = 100; //x position
wmlp.y = 100; //y position
dialog.show();
where X and Y are in pixels.
If you just want to move the alert dialog down, then
alertDialog.getWindow().getAttributes().verticalMargin = 0.2F;
Upvotes: 0