How to make shadow in layer-list?

余生颓废 提交于 2019-12-22 22:23:10

问题


The problem is as follows: I need to make in app widget some actionbar like this:

For this I use layer-list with shape.

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

<!-- Bottom 2dp Shadow -->

<item>
    <shape  android:shape="rectangle">
        <solid android:color="#027668"/>
        <corners android:radius="12dp"/>
    </shape>
</item>

<!-- White Top color -->
<item android:bottom="4dp">
    <shape  android:shape="rectangle">
        <solid android:color="#20a18b" />
        <corners android:radius="7dp" />
    </shape>

</item>

And I get some view:

but, I cant do some around shadow like on first image in this post.

How to do that?


回答1:


Here you go:

Change your drawable background to:

<?xml version="1.0" encoding="utf-8"?><!-- Bottom 2dp Shadow -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#027668" />
            <corners android:radius="12dp" />
        </shape>
    </item>

    <!-- White Top color -->
    <item android:bottom="4dp">
        <shape android:shape="rectangle">
            <solid android:color="#20a18b" />
            <corners android:radius="7dp" />
            <stroke
                android:width="2dp"
                android:color="#027668" />
        </shape>

    </item>
</layer-list>

The results



来源:https://stackoverflow.com/questions/32625737/how-to-make-shadow-in-layer-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!