How to make ripple effect not over fillet boundary for Actionbar's option menu by using AppCompatActivity?

85 Views Asked by At

In Activity‘'s option menu, It has a fillet boundary in default and the ripple effect is not over it.

Option_Menu_In_Activity:

enter image description here

I implement a activity by AppCompatActivity, But It is not default filled boundary like Activity, so I set a theme for AppCompatActivity by below code:

AndroidManifest.xml:

....
        <activity android:name=".MainActivity"
            android:theme="@style/AAA">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

menu.xml:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/reset_setting"
        android:title="设置2"
        android:showAsAction="never"/>
    <item android:id="@+id/add_handle"
        android:title="设置3"
        android:showAsAction="never"/>
    <item android:id="@+id/reset_setting4"
        android:title="设置4"
        android:showAsAction="never"/>
</menu>

themes.xml

    <style name="AAA" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="actionOverflowMenuStyle">@style/OverFlowMenu</item>
    </style>
    <style name="OverFlowMenu" parent="Widget.AppCompat.Light.PopupMenu.Overflow">
        <item name="android:popupBackground">@drawable/menu_popup_background</item>
    </style>

menu_popup_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:top="6dp"
        android:bottom="6dp">
        <shape
            android:shape="rectangle">
            <stroke
                android:color="#fcfcfc"
                android:width="2px" />
            <padding
                android:top="6dp"
                android:bottom="6dp" />
            <corners
                android:radius="26dp" />
            <solid
                android:color="#f2fcfc" />
        </shape>
    </item>
</layer-list>

But I found a issue, when touch menu, the ripple effect will over fillet boundary.

Option_Menu_In_AppcompatActivity:

enter image description here

I also try to set ripple for it, and it is not work.

Any person know that?

0

There are 0 best solutions below