androidandroid-recyclerviewandroid-animationandroid-glide

How do load images in Glide with Animation


I'm using Glide to load images from the server, but they appear suddenly without any animation. I'd like to display the images with a fading animation. Could you please provide some suggestions on how to achieve this effect?


Solution

  • You have to use transitions() API in the GLIDE builder call. Here are 2 possible ways you can achieve this.

    1. By using transitions API : A Helpful Guide | Official Doc

      GlideApp
      .with(context) .load(....) .transition(DrawableTransitionOptions.withCrossFade()) //Here a fading animation .into(....);

    2. By creating a TransitionFactory : SOF Answer by user tudor

      GlideApp.with(this) .load(url) .transition(DrawableTransitionOptions.with(Your_custom_factory)) .into(image)

    Hope this helps