我有一个应用程序,其中有一个简单的列表视图和上下文菜单。
Android 7 之前的版本,一切看起来都正常:
when clicking an item at the bottom of the list:
when clicking an item at the top of the list:
但对于安卓7...
when clicking an item at the bottom of the list:
when clicking an item at the top of the list:
上下文菜单的位置有变化吗?
我在某处找到了解决方案(不记得在哪里)。
问题出在新的上下文菜单和 Holo 主题之间。
解决方案详情:
我在 value-v24 文件夹中添加了一个样式,如下所示:
<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>
然后,在我的默认 styles.xml 中,我使用了一种名为
AppTheme.Common
这定义了我所有的应用程序样式,以及一个名为的空样式
<style name="AppTheme" parent="AppTheme.Common" />
我使用该空样式作为默认应用程序样式。
这样,在版本 > 24 上,应用程序使用有关上下文菜单重叠锚点的此额外项目来解决问题(使上下文菜单恢复到 API 24 之前的样子)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)