What I have read previously
- Add ripple effect to my button with button background color?
- Android ripple for button not working
- Ripples on a shape with a transparent background
- Transparent background in ImageButton with ripple effect?
- RippleDrawable - dev
What I need is to make custom ripple effect cover only alpha channel of my image OR avoid covering transparent spots.
My original botton
<Button
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_gravity="center"
android:background="@drawable/btn_round"
android:foreground="@drawable/btn_ripple"/>
What I have tried from suggested with button
android:background="?attr/selectableItemBackgroundBorderless"
android:foreground="?attr/selectableItemBackgroundBorderless"
. It did not quite work. In fact it ignores borders of my image and shape set in ripple whilst I need to constrain ripple spread shape to alpha channel.
As you already can see I have 3 options to combine
- custom button shape
- custom ripple
- cutting-off alpha channel from suggested options
So I tried transforming button
into imageButton
<ImageButton
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_gravity="center"
android:background="@drawable/btn_round"
android:foreground="@drawable/btn_ripple"
android:scaleType="fitXY"/>
However I have tried all combinations of src
, background
and foreground
for all 3 and did not succeed. Also tried adding
android:background="?attr/selectableItemBackgroundBorderless"
android:foreground="?attr/selectableItemBackgroundBorderless"
to ripple. That doesn't work either.
Reference this picture (that one does not have alpha but that is not the case)