gpt4 book ai didi

android - 在android中的imageview中加载的图像的阴影效果

转载 作者:行者123 更新时间:2023-11-29 01:39:07 25 4
gpt4 key购买 nike

在我的应用程序中,我需要在 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 上显示阴影效果作为延迟加载,但我想要的是即使在加载图像后也能对图像保持相同的效果。任何人都可以就此建议我。提前致谢。

最佳答案

使用Glide library

此库支持动画。检查example

Animation anim = AnimationUtils.loadAnimation(context, android.R.anim.fade_in);

Glide.with(this).load(URL).animate(anim).into(imageView);

关于android - 在android中的imageview中加载的图像的阴影效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25948741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com