Issue
This Content is from Stack Overflow. Question asked by andynewman
I want to override the size of the placeholder and error drawables in Glide. I tried
Glide.with(fragment)
.load(url)
.apply(new RequestOptions()
.placeholder(R.drawable.loading_icon)
.error(R.drawable.loading_error)
.override(200))
and
Glide.with(fragment)
.load(url)
.placeholder(R.drawable.loading_icon)
.error(R.drawable.loading_error)
.apply(new RequestOptions().override(200))
and none of these two solutions work.
While the image is being downloaded, I can clearly see the placeholder image’s displayed size is not 200 pixels, as I expect it to be. override()
seems to work with into()
, but not with placeholder()
or error()
.
I am using Glide 4.13.2 with OkHttp backend:
implementation 'com.github.bumptech.glide:glide:4.13.2'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.13.2'
Solution
You can try add the following line into your Glide configurations, like they mention in this issue https://github.com/bumptech/glide/issues/542:
.dontAnimate()
So it will become something like this:
Glide.with(context)
.load(imageUrl)
.placeholder(placeholderImage)
.override(100, 100)
.dontAnimate()
.into(imageView);
This Question was asked in StackOverflow by andynewman and Answered by João Pedro Pedrosa It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.