Reputation: 60241
I have an old project using Glide 3.5.2. The below works fine.
Glide.with(context)
.load(url)
.override(IMAGE_SIZE_FIX, IMAGE_SIZE_FIX)
.crossFade()
.placeholder(placeholder)
.into(imageView);
However, now I update my Glide to 4.5.0. It complains
Error:(35, 24) error: cannot find symbol method override(int,int)
I tried answer from
Glide-4.0.0 Missing placeholder, error, GlideApp that solve the overide(int,int)
issue. But then the crossfade()
becomes issue.
The ways I tried as below...
Glide.with(context)
.load(url)
.apply(new RequestOptions().override(IMAGE_SIZE_FIX, IMAGE_SIZE_FIX).placeholder(placeholder))
.crossFade()
.into(imageView);
Glide.with(context)
.load(url)
.apply(new RequestOptions().override(IMAGE_SIZE_FIX, IMAGE_SIZE_FIX).placeholder(placeholder).crossFade())
.into(imageView);
Both doesn't work. complaining
Error:(51, 17) error: cannot find symbol method crossFade()
How could I apply .crossFade()
?
Upvotes: 3
Views: 9011
Reputation: 779
Faced same issue with current version of Glide. But later found that if we dont provide the imageview with proper width/height that is if we leave it wrap_content then no matter how fast is your gif it will render very slowly.
Provide fixed width like match_parent or "0dp" and that will do the magic
Upvotes: 2
Reputation: 51
My suggestion It's Is Best
Glide.with(fragment)
.load(url)
.transition(
new DrawableTransitionOptions
.crossFade())
.into(imageView);
Upvotes: 3
Reputation: 1559
To apply a cross fade transition to a particular load, you can use:
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
Glide.with(fragment)
.load(url)
.transition(withCrossFade())
.into(imageView);
Or:
Glide.with(fragment)
.load(url)
.transition(
new DrawableTransitionOptions
.crossFade())
.into(imageView);
Upvotes: 3
Reputation: 69709
FYI
latest dependencies
is
implementation 'com.github.bumptech.glide:glide:4.6.1'
EDIT
Unlike Glide v3
, Glide v4
does NOT apply a cross fade or any other transition by default to requests. Transitions must be applied manually.
To apply a cross fade transition to a particular load, you can use:
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
Glide.with(this)
.load("https://i.sstatic.net/7CChZ.jpg?s=328&g=1")
.transition(withCrossFade())
.apply(new RequestOptions().override(100, 100)
.placeholder(R.drawable.ic_launcher_background)
.error(R.drawable.ic_launcher_background).centerCrop()
)
.into(imageView);
Upvotes: 5