简体   繁体   中英

Android context menu custom positioning?

I have managed to do this for Toasts and Dialog boxes, but now the trouble of context menu has arisen. Is it possible in Android to position a context menu to a different location programmatically? I want to be able to specify the position anywhere on the screen as part of a custom user interface, but I cannot seem to figure out how to do this. Thanks in advance.

As I noted in my comment, I went with a PopupWindow for the actual menu view. It contained a ListView for the menu items with appropriate event listeners. I attached the context menu by overriding the long press listener and adding the PopupWindow at event.getRawY() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM