Previously, I'm using StateDrawable
to achieve custom card view with shadow effect - https://stackoverflow.com/a/33829309/72437 . This is due to the limitation of CardView
, of not able to accept selector in its cardBackgroundColor
Now, I want to add ripple effect. I use the following XML.
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#00ff00">
<item android:drawable="@drawable/statelist_item_background"/>
</ripple>
However, this is having side effect where the green ripple extends till it touches shadow region.
I want to avoid the green ripple from touching shadow region. I try to add in padding information.
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#00ff00">
<item>
<shape android:shape="rectangle">
<padding android:top="10dp" android:right="10dp" android:bottom="10dp" android:left="10dp" />
</shape>
</item>
<item android:drawable="@drawable/statelist_item_background"/>
</ripple>
However, it makes no different. Adding padding information within ripple
tag makes no difference.
May I know how can I have padding for ripple effect?