How to show a PopoupWindow at the click location?
-
29-09-2019 - |
Question
I'm trying to show in Android a PopupWindow at the click location. I read that Android does not support getting the click coordinates for some reason.
I want to do something like the little popup that appears on the contacts on Android 2.1+ when you select a person's icon and a window appears at the row location showing different options to contact that person. Also in the twitter application they do something similar.
I guess it is acting more like a Context Menu, but what I read is that Context Menus cannot be customized. How are this popup windows at location done?
Thanks.
Solution
There is an easier option for the case of PopupWindow:
The method showAsDropDown(View, int offsetx, int offsety)
of the PopupWindow will anchor the window to the given view by the specific offset.
OTHER TIPS
I should have searched more in stackoverflow... There is a sample in this question: How to make Twitter app style Quick Actions on Android
And also here is a guide: http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/