Search code examples
androiddrop-down-menuoverflow-menu

How to build a fast-reacting overflow dropdown menu?


Anroid's default overflow menu dose not respond to quik click correctly. When I double click on the drop down menu, I want to open the menu, and then click on the first item inside it. But the default overflow menu always put my second click somewhere else.
image1
In above gif, the second click always falls upon the 4th item (the first item is 'commit',the 4th 'save as')

However in apps like ebdic or chrome, the overflow menu do respond to fast clicks: ebdic

P.S.,android:popupAnimationStyle and android:windowAnimationStyle are useless here.


Solution

  • After almost 3 hours of frustration, I have my own answer now :)
    At the beginning the overflow menu behaves differently; I can click very fast and get expected result on the default overflow menu of android 4.4 . But in higher versions, the default behaviour alters.
    Yes using AnimationStyle I can do nothing with this, instead I should tweak actionOverflowMenuStyle.

    <style name="toolbarTheme" parent="AppTheme">
        <item name="android:textColorSecondary">@android:color/white</item>
        <item name="colorAccent">@color/colorHeaderBlue</item>
        <item name="actionOverflowMenuStyle">@style/OverflowMenuStyle</item>
        <!--item name="android:popupBackground">@android:color/white</item-->
        <item name="android:popupBackground">@drawable/round_corner_card1_1cor</item>
    </style>
    
    <style name="OverflowMenuStyle">
        <item name="overlapAnchor">true</item>
        <item name="android:dropDownVerticalOffset">0dip</item>
        <item name="android:dropDownHorizontalOffset">0dip</item>
    </style>
    

    note the parent theme of OverflowMenuStyle, leave it blank, or set as "Base.Widget.AppCompat.ListView.Menu".

    result:
    enter image description here