图像视图的底部透明阴影效果



我想为我的ImageView添加阴影效果,就像底部的透明效果一样。这里有两个有阴影效果和没有阴影效果的图像。有什么可能的方法可以做到这一点吗?还是从互联网上获取阴影 svg 文件并放在原始图像视图上更好?

您可以使用如下所示的RelativeLayot将图像与渐变图像放在同一空间中:

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/your_image"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/grad"/>
</RelativeLayout>

"grad"图像是这样的:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:endColor="#181818"
android:startColor="#00000000 " />
<corners android:radius="5dp" />
</shape>

最新更新