Share the post "Add Bottom Shadow In Any Layout Like Cards In Google Now"
Coderwall created a layer list XML drawable in order to achieve this. A big thanks to him! This is how the XML file mydrawable.xml looks like:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle" android:dither="true"> <corners android:radius="2dp" /> <solid android:color="#ccc" /> </shape> </item> <item android:bottom="2dp"> <shape android:shape="rectangle" android:dither="true"> <corners android:radius="2dp" /> <solid android:color="@color/white" /> <padding android:bottom="8dp" android:left="8dp" android:right="8dp" android:top="8dp" /> </shape> </item> </layer-list> |
Make sure you place this in the drawable folder.
To use this, simple set it as the value of the android:background attribute of any layout in your XML.
|
1 2 3 4 5 6 |
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/mydrawable" android:orientation="vertical" > ... </LinearLayout> |
it works! thank you!
Thanks! This was what I want to do.