How to force PopupMenu to overlap anchor?

Ziem picture Ziem · Jan 28, 2015 · Viewed 9.4k times · Source

How to force PopupMenu to overlap anchor? I would like to recreate something similar to this:

Menus usage

Answer

user3426273 picture user3426273 · May 4, 2015

Setting overlapAnchor allowed me to overlap anchor view without setting offset:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="popupMenuStyle">@style/PopupMenu</item>
</style>

<style name="PopupMenu" parent="@style/Widget.AppCompat.Light.PopupMenu">
    <item name="overlapAnchor">true</item>
</style>

The PopupMenu wraps a ListPopupWindow inside it. This ListPopupWindow wraps AppCompatPopupWindow using this overlapAnchor attribute. All this in the support library.