Create a gist now

Instantly share code, notes, and snippets.

@MarsVard /README
Last active Apr 4, 2017

What would you like to do?
android drawable to imitate google cards.
put card.xml in your drawables directory, put colors.xml in your values directory or add the colors to your colors.xml file.
set the background of a view to card,
as you can see in card.xml the drawable handles the card margin, so you don't have to add a margin to your view
``` xml
(here is a screenshot of what the cards look like)[]
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="">
<padding android:top="10dp" android:right="10dp" android:bottom="5dp" android:left="10dp" />
<solid android:color="@color/transparent" />
<padding android:top="0dp" android:right="0dp" android:bottom="1dp" android:left="0dp" />
<solid android:color="@color/card_shadow_1" />
<corners android:radius="2dp" />
<padding android:top="0dp" android:right="0dp" android:bottom="1dp" android:left="0dp" />
<solid android:color="@color/card_shadow_2" />
<corners android:radius="2dp" />
<!-- Background -->
<shape >
<solid android:color="@color/card_background" />
<corners android:radius="2dp" />
<?xml version="1.0" encoding="utf-8"?>
<color name="transparent">#00000000</color>
<!-- card colors -->
<color name="card_background">#ffffff</color>
<color name="card_shadow_1">#d4d4d4</color>
<color name="card_shadow_2">#dddddd</color>
<color name="card_detailing">#eee</color>



Thank you so much


Wowo thumbs up +1


You could as well use system parameter: "@android:color/transparent"


Very much appreciated

ravib21 commented Feb 11, 2016

That's perfect!! (y)


i like :)


Really cool ! Thanks :)
A short question :
Is there a better way to design drawables other than looking at the preview in android studio ?


This is awesome. Thank you and +1 for the work...


How to add click effect color?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment