<?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="#0aF3F4F4" /> <corners android:radius="@dimen/dp_10"/> <padding android:top="2px" android:bottom="2px" android:left="2px" android:right="2px" /> </shape> </item> <item> <shape android:shape="rectangle" > <solid android:color="#0fF3F4F4" /> <corners android:radius="@dimen/dp_10" /> <padding android:top="2px" android:bottom="2px" android:left="2px" android:right="2px" /> </shape> </item> <item> <shape android:shape="rectangle" > <solid android:color="#14F3F4F4" /> <corners android:radius="@dimen/dp_10"/> <padding android:top="2px" android:bottom="2px" android:left="2px" android:right="2px" /> </shape> </item> <item> <shape android:shape="rectangle" > <solid android:color="#19F3F4F4" /> <corners android:radius="@dimen/dp_10"/> <padding android:top="2px" android:bottom="2px" android:left="2px" android:right="2px" /> </shape> </item> <item> <shape android:shape="rectangle" > <solid android:color="#1eF3F4F4" /> <corners android:radius="@dimen/dp_10"/> <padding android:top="2px" android:bottom="2px" android:left="2px" android:right="2px" /> </shape> </item> <item> <shape android:shape="rectangle" > <solid android:color="#23F3F4F4" /> <corners android:radius="@dimen/dp_10"/> <padding android:top="2px" android:bottom="2px" android:left="2px" android:right="2px" /> </shape> </item> <item> <shape android:shape="rectangle" > <solid android:color="#28F3F4F4" /> <corners android:radius="@dimen/dp_10"/> <padding android:top="2px" android:bottom="2px" android:left="2px" android:right="2px" /> </shape> </item> <item> <shape android:shape="rectangle" > <solid android:color="#2dF3F4F4" /> <corners android:radius="@dimen/dp_10"/> <padding android:top="2px" android:bottom="2px" android:left="2px" android:right="2px" /> </shape> </item> <item> <shape android:shape="rectangle" > <corners android:radius="@dimen/dp_10"/> <gradient android:startColor="#EBF5FF" android:endColor="#FFFFFF" android:angle="270" android:type="linear" /> </shape> </item> </layer-list>
原理其实就是一层一层往上盖,padding就是里面的小抽屉比外面的大抽屉从left,right,top,bottom上分别小多少像素文章来源:https://www.toymoban.com/news/detail-513895.html
多盖几层,也就出来阴影了,越往上面这层颜色也就越深,也就是颜色从0a变到2d,最后一个shape也就是最上面这层的颜色,这里用gradient做的从上到下的渐变色文章来源地址https://www.toymoban.com/news/detail-513895.html
到了这里,关于Android shape定义背景带阴影的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!