shape画一个阴影-阿里云开发者社区

开发者社区> 开发与运维> 正文
登录阅读全文

shape画一个阴影

简介: 在项目中用到了画阴影,借鉴了别人的思路,以后有空再用java代码画一个,先看效果 其实有时候,不需要写代码的,太麻烦了 .9.png 阴影生成器 Paste_Image.

在项目中用到了画阴影,借鉴了别人的思路,以后有空再用java代码画一个,先看效果
其实有时候,不需要写代码的,太麻烦了 .9.png 阴影生成器

Paste_Image.png
  • 怎么用?

android:background="@drawable/layer_list_shadow_rectangle"

..

layer_list_shadow_oval
layer_list_shadow_rectangle

<pre>
<?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="@color/cardShadowColor_1" />
<corners android:radius="@dimen/cardRadius" />
<padding
android:bottom="@dimen/cardPadding"
android:left="@dimen/cardPadding"
android:top="@dimen/cardPadding"
android:right="@dimen/cardPadding" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/cardShadowColor_2" />
<corners android:radius="@dimen/cardRadius" />
<padding
android:bottom="@dimen/cardPadding"
android:left="@dimen/cardPadding"
android:top="@dimen/cardPadding"
android:right="@dimen/cardPadding" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/cardShadowColor_3" />
<corners android:radius="@dimen/cardRadius" />
<padding
android:bottom="@dimen/cardPadding"
android:left="@dimen/cardPadding"
android:top="@dimen/cardPadding"
android:right="@dimen/cardPadding" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/cardShadowColor_4" />
<corners android:radius="@dimen/cardRadius" />
<padding
android:bottom="@dimen/cardPadding"
android:left="@dimen/cardPadding"
android:top="@dimen/cardPadding"
android:right="@dimen/cardPadding" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/cardShadowColor_5" />
<corners android:radius="@dimen/cardRadius" />
<padding
android:bottom="@dimen/cardPadding"
android:left="@dimen/cardPadding"
android:top="@dimen/cardPadding"
android:right="@dimen/cardPadding" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/cardShadowColor_6" />
<corners android:radius="@dimen/cardRadius" />
<padding
android:bottom="@dimen/cardPadding"
android:left="@dimen/cardPadding"
android:top="@dimen/cardPadding"
android:right="@dimen/cardPadding" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/cardShadowColor_7" />
<corners android:radius="@dimen/cardRadius" />
<padding
android:bottom="@dimen/cardPadding"
android:left="@dimen/cardPadding"
android:top="@dimen/cardPadding"
android:right="@dimen/cardPadding" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/cardShadowColor_8" />
<corners android:radius="@dimen/cardRadius" />
<padding
android:bottom="@dimen/cardPadding"
android:left="@dimen/cardPadding"
android:top="@dimen/cardPadding"
android:right="@dimen/cardPadding" />
</shape>
</item>

<item>
    <shape android:shape="rectangle">
        <corners android:radius="3dp" />
        <solid android:color="@color/cardBodyColor" />
        <padding android:bottom="@dimen/cardRadius"
            android:top="@dimen/cardRadius"
            android:left="@dimen/cardRadius"
            android:right="@dimen/cardRadius"
            />
    </shape>
</item>

</layer-list>
</pre>

shadow_color_radius

<pre>
<?xml version="1.0" encoding="utf-8"?>
<resources>

<color name="cardBodyColor">#FFFFFF</color>
<color name="cardShadowColor_1">#0a8c8c8c</color>
<color name="cardShadowColor_2">#0f898989</color>
<color name="cardShadowColor_3">#14898989</color>
<color name="cardShadowColor_4">#19898989</color>
<color name="cardShadowColor_5">#1e898989</color>
<color name="cardShadowColor_6">#23898989</color>
<color name="cardShadowColor_7">#28898989</color>
<color name="cardShadowColor_8">#2d898989</color>
<dimen name="cardPadding">2px</dimen>
<dimen name="cardRadius">10dp</dimen>

</resources>
</pre>

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

其他文章