问题
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