Closed XinyueZ closed 8 years ago
Can you please share your code and vector so I can try and build on it?
I think all you need is to get a drawable from compat and then pass it to .placeholder()
. Maybe needs starting as well. If vector drawable uses level to animate then you need a progressbar, or animate the level yourself.
I just tried this and it works perfectly fine, here's a checklist:
<21
. Animated Vector Drawables altogether are not supported <11
.<animated-vector>
that works, I used the clock from https://github.com/chiuki/animated-vector-drawableandroid.defaultConfig.vectorDrawables.useSupportLibrary = true
in build.gradle
setCompatVectorFromResourcesEnabled
for support v24.0.0:
// don't forget <application android:name=".App">
public class App extends android.app.Application {
@Override public void onCreate() {
super.onCreate();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
}
Get the drawable and make sure it's started:
Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.animated_vector);
if (drawable instanceof Animatable) {
((Animatable)drawable).stop(); // required in case the drawable was reused
((Animatable)drawable).start(); // required to start the animation
}
Full working example in commit linked just above this comment: as a bonus there's crossFade and the loaded image is a GIF animation.
I wann use Glide and avoid using Progress controller to make a loading indicator. I try with animate-vector-drawable-compat and using scrCompat , start() call whatever like example codes official. But it doesn't work.