Guys, is there anyone who can share animated loading drawable that I can use as placeholder while image is loading?
I mean this:
Glide.with(ctx)
.load(imageUrl)
.placeholder(NEED_THIS_PLACEHOLDER)
.crossFade()
.into(image);
Thanks in advance!
No one? ;(
I copied the first example (<animation-list>) from Drawable Animation, put it into drawable-nodpi/progress.xml, removed oneshot and added .placeholder(R.drawable.progress) and it just works (it displays as animation while the load completes).
I'm guessing you have tried that too, if you did, what is it exactly you're looking for?
Another option to use a stock spinner (but it will upscale):
// .placeholder(getProgressBarIndeterminate())
Drawable getProgressBarIndeterminate() {
final int[] attrs = {android.R.attr.indeterminateDrawable};
final int attrs_indeterminateDrawable_index = 0;
TypedArray a = getContext().obtainStyledAttributes(android.R.style.Widget_ProgressBar, attrs);
try {
return a.getDrawable(attrs_indeterminateDrawable_index);
} finally {
a.recycle();
}
}
Hey @TWiStErRob,
Thanks for looking into this. I've just tested the method you wrote and while it works - I ran into two problems:
I've also tried first method you suggested (animation xml) and surprisingly it is also not animated... I am using Genymotion emulator and android 4.1.
I would just love if library supported some kind of default placeholder that's animated since probably all the people who use the library do their own loading indicators. If needed - I can supply graphics from designer in our team - just need to know what format graphics should be - do we need 10 per second, 30 per second? Vector probably in order to scale well on all screens? Default padding?
Let me know.
Glide doesn't have any resources built-in and we're not planning to include any either. I see what you mean though. I had the same problem with Material design: it is awesome, but you need to create your own "plus" icon to go in FAB. I think the reason is the same: any Drawable can be out of place if your app's theme is customised. Also sizing and padding can be really different. You need different placeholders for thumbs and full screen images.
As far as I remember the animation was playing for me, try the linked example between our last 2 comments.
Are you using CircleImageView by any chance?
https://github.com/bumptech/glide#compatibility
See #505 if placeholder is still not animating.
Most helpful comment
Another option to use a stock spinner (but it will upscale):