AnimaVivens
AnimaVivens

Reputation: 409

How to reset AnimatedVectorDrawable animations in Android when an Activity is returned to under version 23?

Scenario: I have a shape as an AnimatedVectorDrawable instance inside an ImageView. When this shape (ImageView) is clicked on, it performs an animation. After this animation ends, a new Activity is executed. Then, when using the return button on my smartphone, the first Activity is displayed. To make the AnimatedVectorDrawable appear in it's original state (with no animation applied), it's method reset() can be called above android sdk version 23. Example:

    public void onStop() {
        super.onStop();

        avdLogo.reset()
    }

avdLogo refers to the AnimatedVectorDrawable in question.

How can I achieve the same below version 23?

Upvotes: 3

Views: 952

Answers (1)

PushpikaWan
PushpikaWan

Reputation: 2545

Add vectorDrawables.useSupportLibrary = true to your defaultConfig in the android section of your module’s build.gradle. like below

android {
     ........       
      ........

    defaultConfig {
       ........
       vectorDrawables.useSupportLibrary = true
    }

It will support animated-vector drawable file to compatible use with APIs lower than Lollipop.

Upvotes: 1

Related Questions