- Rounded Corners
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<solid android:color="#C8C8C8" />
<corners
android:bottomLeftRadius="10dp"
android:bottomRightRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp" />
</shape>
<solid android:color="#FFFFFF" />
<stroke
</shape>
__________________________________________________________________
- Rectangle frame
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FFFFFF" />
<stroke
android:width="1dp"
android:color="#CCCCCC" />
</shape>
__________________________________________________________________
Use of <layer-list> in drawable (xml)
- Rounded Corners with Shadow
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Shadow At Bottom-->
<item>
<shape android:shape="rectangle" >
<solid android:color="#d8d8d8" />
<corners android:radius="10dp" />
</shape>
</item>
<!-- White Color At Top -->
<item android:bottom="3px">
<shape android:shape="rectangle" >
<solid android:color="#FFFFFF" />
<corners android:radius="10dp" />
</shape>
</item>
</layer-list>
__________________________________________________________________
- Rectangle frame with Shadow
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<solid android:color="#00CCCCCC" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<solid android:color="#10CCCCCC" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<solid android:color="#20CCCCCC" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<solid android:color="#30CCCCCC" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp" />
<solid android:color="#50CCCCCC" />
</shape>
</item>
<!-- Background -->
<item>
<shape>
<solid android:color="@color/White" />
<corners android:radius="3dp" />
</shape>
</item>
</layer-list>
Change padding in all items and see the difference.
e.g.
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
__________________________________________________________________
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- dropshadow -->
<item>
<shape>
<solid android:color="#10CCCCCC" />
<padding
android:bottom="3dp"
android:left="3dp"
android:right="0dp"
android:top="0dp" />
</shape>
</item>
<item>
<shape>
<solid android:color="#20CCCCCC" />
<padding
android:bottom="3dp"
android:left="3dp"
android:right="0dp"
android:top="0dp" />
</shape>
</item>
<item>
<shape>
<solid android:color="#40CCCCCC" />
<padding
android:bottom="3dp"
android:left="3dp"
android:right="0dp"
android:top="0dp" />
</shape>
</item>
<item>
<shape>
<solid android:color="#50CCCCCC" />
<padding
android:bottom="3dp"
android:left="3dp"
android:right="0dp"
android:top="0dp" />
</shape>
</item>
<item>
<shape>
<solid android:color="#60CCCCCC" />
<padding
android:bottom="3dp"
android:left="3dp"
android:right="0dp"
android:top="0dp" />
</shape>
</item>
<!-- content background -->
<item>
<shape>
<solid android:color="#FDC650" />
</shape>
</item>
</layer-list>
No comments:
Post a Comment