I'm trying to create a ripple with rounded corners for the Drawer items. However, I can't figure out how to achieve that. I tried to create a custom ripple and assign it to the NavigationView
through app:itemBackground
property as follows:
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view"
style="@style/Widget.MaterialComponents.NavigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/menu_navigation"
app:itemBackground="@drawable/custom_ripple"/>
custom_ripple
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="#000000" />
<corners android:radius="15dp" />
</shape>
</item>
<item android:drawable="@drawable/rounded_corner" />
</ripple>
rounded_corner
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorAccentTransparent" />
<corners android:radius="6dp" />
</shape>
However, this doesn't work as expected. There seem to be two ripples: a rectangle and a ripple with rounded corners as you can see below.
Have you any idea how to solve this? Thanks