question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crossfade doesn't smoothly transition between images

See original GitHub issue

Hi there. Is it possible to achieve proper crossfade between two images ( not the placeholder ), by loading one and then the other?

I apply a crossfade between a series of images but it isn’t a true smooth crossfade. The original disappears, is replaced by just black, then the new image fades in. So you always see this black, ‘empty’ image in between the transitions, instead of a smooth true crossfade. Is there a way to fix this?

Running version 1.1.0 ( was on 1.0.0 before with same problem ) Loading the image like this:

load(images[currentIndex].path) {
            crossfade(600)
}

I tried simply using crossfade(true) I also tried transition(CrossfadeTransition(600, true))

But the result is always a ‘false’ crossfade. It’s really just the first image disappearing, a short instant of black/empty image, then the new image fading in.

I’m assuming you simply can’t crossfade two images without using two imageviews, but wanted to check.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ThomasArtProcessorscommented, Dec 17, 2020

Not sure what happened last time but I tried this again and the code works fine and keeps working as I cycle through the same images continually… It does give me a memory leak on the other hand, but I will look into that. Thanks!

0reactions
JJSarrasincommented, Mar 4, 2022

For my case, I only need the following snippet to avoid the black blink effect (I need to disable cache policy, that’s maybe not your need)

val request = ImageRequest.Builder(context)
      .data(url)
      .crossfade(0)
      .memoryCachePolicy(CachePolicy.DISABLED)
      .target(object : TransitionTarget {
          override val drawable get() = cardView.showImageView.drawable
          override val view get() = cardView.showImageView
          override fun onSuccess(result: Drawable) {
              myImageVie.setImageDrawable(result)
          }
      })
      .build()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Crossfading Images in SwiftUI doesn't seem to work
I've managed to get an array of Colors to crossfade nicely between them using the following code snippets, but if I replace the...
Read more >
How To Create A Cross Dissolve And Cross Fade Transition ...
DaVinci Resolve Tutorial #75. This video explore how to make a smooth transition between visual and audio edits in a DaVinci Resolve project ......
Read more >
Crossfading Images
Demo 6 -Fading between multiple images on click​​ This is very similar to the others – just layout the images on top of...
Read more >
Simple jQuery image crossfade - Simon Battersby
A demo, code and explanation for a simple jQuery crossfade image cycler. ... I keep going back to it for the smooth, reliable...
Read more >
Crossfade audio in Final Cut Pro - Apple Support
A crossfade is a common type of audio transition between two clips, in which the first clip's audio fades down while the second...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found