在我的应用程序中,我需要在imageview中加载的图像上添加阴影效果(来自url)。 以下是我尝试过的事情: -
xml代码: -
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"
android:background="@drawable/shadow_effect_imageview"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_margin="0.2dp"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="0.7"
android:contentDescription="@string/app_name"
android:scaleType="fitXY"/>
</LinearLayout>
shadow_effect_imageview的代码: -
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#FFFFFF"
android:centerColor="#CCCCCC"
android:endColor="#595959"
android:angle="270"
>
</gradient>
</shape>
但是使用它们会在imageview上显示阴影效果作为延迟加载,但我想要的是即使在加载图像后也能保持对图像的相同效果。 有人请建议我这个。 提前谢谢。
答案 0 :(得分:1)
此库支持动画。 查看example
动画动画= AnimationUtils.loadAnimation(context,android.R.anim.fade_in);
Glide.with(this).load(URL).animate(anim).into(imageView);