zawadz88/MaterialPopupMenu

Not able to position the popup menu below the view anchor

ogasimli opened this issue · 6 comments

I am not able to position the popup menu below the view anchor like in this picture:

https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/pop-up-menu-android-application/Images/image012.png

I have tried to set dropdownGravity = Gravity.BOTTOM without success. I have also tested with other Gravity constants (i.e END, START, TOP, etc.) but wasn't able to achieve the desired result.

Hi @ogasimli,
Sorry for not replying earlier but I was on holidays. I'll try to have an answer for you by the end of the week.

Hi @ogasimli,
I've checked and this is not possible currently. It is a nice enhancement though and should relatively easy to add!
I'll try to have something soon.

Hi @zawadz88,

Thanks for your time. I also think that it is vital to be able to position the Menu. In my case, I am animating the icon when popup menu is opened and closed. Therefore, this feature was very important to me. Also, I noticed that there is no OnCloseListener. I think that it will be a good enhancement either.

Because of these 2 issues, I decided to create my own custom PopupWindow. Nevertheless, thanks for this great library.

I have something ready which you might try here (See "Custom offsets" sample): https://github.com/zawadz88/MaterialPopupMenu/tree/feature/custom-offsets

Using dropdownGravity seems like a more generic approach though, but it'll require further investigation as depending on the amount of space available (top/bottom of the screen) the results might differ.

Thanks!

Yes, positioning via the dropdownGravity would much more elegant. But custom offsets are also doing the job. Having both gravity and custom offset would be the best solution though. I.e in my custom PopupWindow I have set the gravity of the menu and then adjusted its position slightly with custom offsets.

Using dropdownGravity = Gravity.BOTTOM and custom offset is now released as part of 2.2.0.
Thanks for reporting this :)