android - Ripple effect using itemBackground on NavigationView -
i wonder if having problems when redefining background of items on navigationview app:itembackground"
? behavior shown on screenshot, no matter item press last item shows ripple instead.
here drawer_menu.xml
:
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group android:checkablebehavior="single" android:id="@+id/first_group"> <item android:id="@+id/nav_home" android:icon="@drawable/ic_home" android:title="@string/nav_home" /> </group> <group android:id="@+id/second_group"> <item android:id="@+id/nav_settings" android:title="@string/nav_settings" /> <item android:id="@+id/nav_about" android:title="@string/nav_about" /> <item android:id="@+id/nav_logout" android:title="@string/nav_logout" /> </group> </menu>
my my_ripple.xml
:
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="#ffff0000"> <item android:id="@android:id/mask" android:drawable="@android:color/white" /> </ripple>
my navigationview:
<android.support.design.widget.navigationview android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:background="@android:color/white" app:headerlayout="@layout/drawer_header" app:itembackground="@drawable/my_ripple" app:itemicontint="@color/drawer_item" app:itemtextcolor="@color/drawer_item" app:menu="@menu/drawer_menu" />
apply itembackground
attribute menu
rather navigationview
. ripple stay contained menu item handling touch event.
Comments
Post a Comment