Wednesday 29 December 2021

PopupWindow .showAsDropDown() unable to shift left or right (But up and down both work)

I've inflated a PopupWindow using the method .showAsDropDown() however I'm not sure why It's now allowing me to shift it right or left. It works perfectly fine when shifting up and down.

public class TestWindow extends PopupWindow {

    private final Context context;

    public TestWindow (Context context) {
        super(context);
        this.context = context;

        setupView();
    }

    private void setupView() {
        View view = LayoutInflater.from(context)
                .inflate(R.layout.popup_test, null);
      

        ...

        setContentView(view);
    }
}
PopupWindow popupWindow = new TestWindow(context);
popupWindow.showAsDropDown(anchorButton, 50, -30);

enter image description here

Shifting the menu up by 30 works perfectly fine, but also I'm trying to shift it towards the left and it's not working. What am I doing incorrectly?

Note:

I've already tried it with 50 and -50 so I'm at lost why it's not moving horizontally



from PopupWindow .showAsDropDown() unable to shift left or right (But up and down both work)

No comments:

Post a Comment