如何使溢出弹出菜单以免阻碍行动起来吧? [英] How to make the overflow popup menu avoid obstructing the action bar?

查看:219
本文介绍了如何使溢出弹出菜单以免阻碍行动起来吧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序 ,当我'已经更新到新的支持库,也试穿了棒棒糖,我注意到一个奇怪的问题:在操作栏的溢出点击按钮时(甚至是新的<一个href="http://developer.android.com/reference/android/widget/Toolbar.html">Toolbar类)将显示在操作栏上方的弹出式菜单,隐藏等操作项目,因为这样的:

On my app, when I've updated to the new support library and also tried on Lollipop, I've noticed a weird issue: when clicking on the overflow button of the action bar (or even the new Toolbar class) will show the popup menu on top of the action bar, hiding other action items, as such:

下面,这让隐藏的操作项是卸载和分享。

Here, the action items that got hidden are uninstallation and sharing.

我试图避免这个问题,通过ovverriding溢出菜单的风格,但没有任何帮助。

I've tried to avoid this issue, by ovverriding the style of the overflow menu, but nothing has helped.

不仅如此,但似乎这是 有意的行为 ,但在已更新有材料设计的许多谷歌应用程序,此行为不成立,因为我已经报道<一href="https://$c$c.google.com/p/android-developer-$p$pview/issues/detail?id=1951">here.

Not only that, but it seems this is an intentional behavior, yet in many Google apps that were updated to have Material design, this behavior doesn't hold, as I've reported here.

我试着在我使用的主题创建此。其实我的主题是非常不同的,其父是Theme.AppCompat.Light.NoActionBar(我用的是工具栏的动作条),但这个片段有这个问题了,所以我认为,如果一个人将得到解决对方会了。

I've tried creating this in the theme I use . Actually my theme is very different and its parent is "Theme.AppCompat.Light.NoActionBar" (and I use the Toolbar as the actionBar), but this snippet has this issue too, so I think that if one will be solved the other will too.

总之,这里的代码片段:

Anyway, here's the snippet:

<resources xmlns:tools="http://schemas.android.com/tools">

    <style name="AppBaseTheme" parent="Theme.AppCompat.Light"></style>

    <style name="AppTheme" parent="AppBaseTheme">
        <item name="android:actionOverflowMenuStyle" tools:targetApi="21">@style/OverflowMenu</item>
    </style>

    <style name="OverflowMenu" parent="@android:style/Widget.Material.PopupMenu.Overflow" tools:targetApi="21">
        <item name="android:overlapAnchor">false</item>
        <item name="android:dropDownVerticalOffset">50dip</item>
    </style>

</resources>

这两个属性没有改变任何东西。

Both attributes didn't change anything.

我也试着找它是如何工作的支持库,但找不到它。

I've also tried looking for how it works in the support library, but couldn't find it.

如何让我的溢出行动项目的弹出式菜单,以避免隐藏其他项目?

How do I make the popup menu of the overflow action item to avoid hiding other item?

推荐答案

如果您使用的是ActionBarActivity,你需要重写溢出菜单样式的appcompat版本随着弹出的属性,如适用的appcompat版本

If you're using ActionBarActivity, you'll need to override the appcompat version of the overflow menu style along with the appcompat versions of the popup attributes, where applicable.

<resources>
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light" />

    <style name="AppTheme" parent="AppBaseTheme">
        <item name="actionOverflowMenuStyle">@style/OverflowMenu</item>
    </style>

    <style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
        <!-- Required for pre-Lollipop. -->
        <item name="overlapAnchor">false</item>

        <!-- Required for Lollipop. -->
        <item name="android:overlapAnchor">false</item>
    </style>

</resources>

这篇关于如何使溢出弹出菜单以免阻碍行动起来吧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆