Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default cross fade animation for Glide V4

With glide v4 default cross fade animation removed. I updated my Glide version to 4 and I want to set a default cross fade animation, not to set for every image load request.

I tried to do it in AppGlideModule extended class which name is "Generated API" at setDefaultTransitionOptions but I failed.

How can I set default cross fade animation in Glide v4?

like image 874
VolkanSahin45 Avatar asked Oct 12 '18 09:10

VolkanSahin45


3 Answers

I did it with this code:

builder.setDefaultTransitionOptions(Drawable.class, DrawableTransitionOptions.withCrossFade());
like image 137
VolkanSahin45 Avatar answered Nov 20 '22 04:11

VolkanSahin45


This works for me:

Glide.with(context).load(image).transition(DrawableTransitionOptions.withCrossFade()).into(view);

like image 45
6rchid Avatar answered Nov 20 '22 06:11

6rchid


You can use this way, it is simple you can also add duration to your transition

 Uri image= Uri.parse(url_of_the_image);
 Glide.with(context)
      .load(image)
      .transition(DrawableTransitionOptions.withCrossFade(duration_in_ms)) 
      .into(imageView);`



  
like image 7
MrinmoyMk Avatar answered Nov 20 '22 06:11

MrinmoyMk