在Android XML中实现透明椭圆形下方的阴影

3
我希望在椭圆形下面有一个阴影(见下图),但由于形状是透明的颜色,我无法弄清楚如何做到这一点。因此,我不能使用layerlist,否则您会通过按钮看到形状而不是背景。我也尝试过半透明阴影,这种方法可行,但效果不好,我更喜欢阴影是黑色的。
这就是我想要的样子。

enter image description here

提前感谢您

1个回答

0

将以下文件设置为您的视图背景以添加阴影效果

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
    <shape android:shape="oval">
        <solid android:color="@color/grey"/>
        <!--shadow Color-->
    </shape>
</item>

<item
    android:left="0dp"
    android:right="0dp"
    android:top="0dp"
    android:bottom="3dp">
    <shape android:shape="oval">
        <solid android:color="@color/white"/>
    </shape>
</item>


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接