Closed egek92 closed 6 years ago
Did you show up using below method?
.showAtCenter(View anchor);
or
.showAtCenter(View layout, 0, 0);
I am also getting the same issue. I have a button at center of the screen, on button click i want to show popup menu. Button is also the anchor view i want popup to appear at button/anchor's center, but popup menu always show/align at left edge of button. By using
.showAtCenter(View anchor); or .showAtCenter(View layout, 0, 0);
It appear at center but does not appear above the anchor view. I want it to appear above and center of the anchor view
In that case, need to set xOffset and yOffset.
final Button button = findViewById(R.id.button2);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
hamburgerMenu.showAsDropDown(view, view.getMeasuredWidth()/2, -view.getMeasuredHeight()/2);
}
});
Use the showAsDropDown view to set the position in relation to the anchor view. Otherwise, you can use showAtLocation. And you can manipulate positions using xOffset and yOffset.
@skydoves this does not worked in my case
hamburgerMenu.showAsDropDown(view, view.getMeasuredWidth()/2, -view.getMeasuredHeight()/2);
But to manipulate positions using xOffset and yOffset i need popupwindow width/height but i couldn't access it using your API. So i have now setWith(popupWidth) and then calculated the position like this
int xOffset = view.getMeasuredWidth() / 2 - popupWidth / 2; powerMenu.showAsDropDown(view, xOffset, 0);
Thanks
@egek92 @nomizodiac below method is added at v2.0.3
.showAsAnchorCenter(View anchor);
and it looks more nature using with
.setAnimation(MenuAnimation.SHOW_UP_CENTER)
I have a view that has width of match_parent it's also my view anchor, I want toshow my pop-up from this view's center but it either show up from left or right