Error:(35, 24) error: cannot find symbol method crossFade() in latest Glide

Refresh

April 2019

Views

1.9k time

1

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()?

1 answers

3

FYI latest dependencies is

implementation 'com.github.bumptech.glide:glide:4.6.1'

EDIT

Cross fades

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.stack.imgur.com/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);