VolkanSahin45
VolkanSahin45

Reputation: 1968

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?

Upvotes: 11

Views: 11200

Answers (3)

6rchid
6rchid

Reputation: 1301

Current way to do this in Glide:

Glide.with(context)
    .load(imageUrl)
    .transition(DrawableTransitionOptions.withCrossFade())
    .into(imageView)

Upvotes: 19

MrinmoyMk
MrinmoyMk

Reputation: 603

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



  

Upvotes: 7

VolkanSahin45
VolkanSahin45

Reputation: 1968

I did it with this code:

builder.setDefaultTransitionOptions(Drawable.class, DrawableTransitionOptions.withCrossFade());

Upvotes: 13

Related Questions