I had a similar task. Let me explain how I solve this. It displays circular images with shadow and ripple effects that do not go beyond the boundaries of the circle.
<ImageView android:id="@+id/iv_undo" android:layout_width="@dimen/iv_width_altmenu" android:layout_height="@dimen/iv_height_altmenu" android:src="@drawable/undo" android:elevation="@dimen/elevation_buttons" android:foreground="@drawable/ripple_effect" android:background="@drawable/buttons_inactive_coloring" />
The following provides a ripple effect:
android:foreground="@drawable/ripple_effect"
Below is the imageView circle.
android:background="@drawable/buttons_inactive_coloring"
The following provides the shadow:
android:foreground="@drawable/ripple_effect"
Another problem you may encounter is the ripple effect that goes beyond the circle. To solve, use the following file (ripple_effect.xml)
<ripple xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:color="@color/button_active" tools:targetApi="lollipop"> <item android:id="@android:id/mask"> <shape android:shape="oval"> <solid android:color="@color/button_active" /> </shape> </item> </ripple>
If you are not using the following:
<item android:id="@android:id/mask"> <shape android:shape="oval"> <solid android:color="@color/button_active" /> </shape> </item>
the ripple effect goes beyond the boundaries of the circle, and it does not look beautiful. Be careful and calm down.
oiyio
source share