前端时间做项目用glide来加载图片,由于加载图片的位置比较多,为了防止加载图片动画后续有更改,鄙人小小的封装了一下,
public class GlideUtils {
public static void load(Context context,String url, ImageView iv){
Glide.with(context).load(url).animate(R.anim.glide_pic).error(R.drawable.ic_default_image).placeholder(R.drawable.holderlit).into(iv);
}
public static void load(Fragment fragment, String url, ImageView iv){
Glide.with(fragment).load(url).animate(R.anim.glide_pic).error(R.drawable.ic_default_image).placeholder(R.drawable.holderlit).into(iv);
}
public static void load(Activity activity, String url, ImageView iv){
Glide.with(activity).load(url).animate(R.anim.glide_pic).error(R.drawable.ic_default_image).placeholder(R.drawable.holderlit).into(iv);
}
}
动画文件glide_pic.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="-50%p" android:toYDelta="0"
android:duration="@android:integer/config_mediumAnimTime"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
duration是400,根据自己的需求来设置