ContextMenu position mixed up in Android 7

I have an application with a simple list and context menu. pre android 7, everything looks fine:

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

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

But wit android 7 ...

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

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

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

+5
source share
1 answer

I found a solution for this somewhere (I don’t remember where). The problem is the new context menu and Golo themes.

Solution Details:

I added a style to the -v24 values ​​folder, which looks like this:

<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 

This defines my whole application style and empty style called

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

and I used this empty style as the default application style. Thus, in version> 24, the application uses this additional element in the context menu overlap binding to fix the problem (casting the context menu into something that looked like API 24)

+8
source

Source: https://habr.com/ru/post/1260526/


All Articles