amitfr
amitfr

Reputation: 1093

ContextMenu position is messed up in Android 7

I have an app with a simple listview and context menu in it. pre android 7, everything looks ok:

when clicking an item at the bottom of the list: enter image description here

when clicking an item at the top of the list: enter image description here

But wit android 7...

when clicking an item at the bottom of the list: enter image description here

when clicking an item at the top of the list: enter image description here

Was there any change in the position of the context menu?

Upvotes: 9

Views: 2175

Answers (2)

Assan Murad
Assan Murad

Reputation: 29

If anyone still has the same problem, just add this to your theme folder (v14)

<item name="android:overlapAnchor">true</item>

Upvotes: 4

amitfr
amitfr

Reputation: 1093

I found a solution for this somewhere (can't remember where). The problem is between the new context menu and the Holo themes.

Solution Details:

I added a style in values-v24 folder that looks like:

<resources>

<style name="ContextPopupMenuStyleLight" parent="@android:style/Widget.Holo.Light.PopupMenu">
    <item name="android:overlapAnchor">true</item>
</style>

<style name="ContextPopupMenuStyleDark" parent="@android:style/Widget.Holo.PopupMenu">
    <item name="android:overlapAnchor">true</item>
</style>

<style name="AppTheme" parent="AppTheme.Common" >
    <item name="android:contextPopupMenuStyle">@style/ContextPopupMenuStyleLight</item>
</style>

Then, in my default styles.xml I used a style called

AppTheme.Common

That defines all my app style, and an empty style called

<style name="AppTheme" parent="AppTheme.Common" />

and I used that empty style as the default app style. This way, on version > 24, the app uses this extra item regarding context menu overlap anchor to fix the issue (bringing context menu to what they looked like before API 24)

Upvotes: 13

Related Questions