How change position of popup menu on android overflow button?

后端 未结 5 2145
再見小時候
再見小時候 2020-12-06 01:46

I just like to implement somethings same as popup menu in the Gmail app, anchored to the overflow button at the top-right. for that I used the same code as google tutorial f

5条回答
  •  难免孤独
    2020-12-06 02:27

    After trying out each approach that I have found, I would think putting an anchoring view might still be an easier and simpler way, especially when you are using a more flexible layout, e.g. ConstraintLayout.

    Just put an invisible view to where you want the popup menu to anchor:

    
    

    Then use it as the anchoring view instead:

        mPopupMenu = new PopupMenu(getActivity(), mPopupMenuAnchor);
    

    Boom, it is done.

提交回复
热议问题