Wednesday, May 28, 2014

custom shapes

shadow for your views using custom shapes





It’s easy to create a shadow for your views using custom shapes.
The idea it’s that you create the shadow layer as background first and the content layers on top of that.
But you also need to displace the layers in order to create the shadow effect.
For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <layer-list>
            <item android:bottom="4dp" android:bottom="4dp">

                <!-- SHADOW LAYER -->
            </item>
            <item android:left="4dp" android:top="4dp">
                <!-- CONTENT LAYER-->
            </item>
        </layer-list>
    </item>
</selector>
You can control the shadow direction n and size through the top, bottom, right and leftparameters.