2014-09-20 49 views
2

在imageview中加载的图像的阴影效果我需要在imageview(从url)加载的图像上添加阴影效果。 下面是我还没有尝试过的事情: -在我的应用程序中的android

代码的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

也许这对你有好处http://square.github.io/picasso/ – 2014-09-20 14:07:15

回答

1

使用Glide library

动画在这个库的支持。 检查example

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

Glide.with(this).load(URL).animate(anim).into(imageView); 
相关问题