11

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?

Zoe
  • 27,060
  • 21
  • 118
  • 148
VolkanSahin45
  • 1,922
  • 12
  • 25

3 Answers3

17

This works for me:

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

6rchid
  • 1,074
  • 14
  • 19
12

I did it with this code:

builder.setDefaultTransitionOptions(Drawable.class, DrawableTransitionOptions.withCrossFade());
VolkanSahin45
  • 1,922
  • 12
  • 25
7

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);`



  
MrinmoyMk
  • 551
  • 7
  • 21