I have a custom cell for an Android ListView. This custom cell is a relative layout with some views inside. There is a space between each cell, so I want to add to the bottom of the cells a shadow.
I've been googling around but couldn't found anything? I want to achieve something similar to this:
Thanks!
Can be done in below two ways:
Using layer-list - Create new file in "res/drawable" which contains:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape
android:shape="rectangle">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="5dp"/>
</shape>
</item>
<item android:right="1dp" android:left="1dp" android:bottom="2dp">
<shape
android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
Then add this layer-list file as background in your List item Layout(ie., Linearlayout or etc..).
The easiest way is definitely to build the shadow into a 9-patch. An example of something like this is:
This is way larger than it needs to be, as a 9-patch, but I wanted to make it larger for example's sake.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With