0

I have animation drawable

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
        android:oneshot="true">
    <item            android:duration="70"            android:drawable="@mipmap/scene00089"/>
    <item            android:duration="70"            android:drawable="@mipmap/scene00088"/>
    <item            android:duration="70"            android:drawable="@mipmap/scene00087"/>
    <item            android:duration="70"            android:drawable="@mipmap/scene00086"/>
    //......

Which should be played only when I drag right(normally runs) or left(reversed). I have already implemented how to play it reverse using another file with reversed animation, but the only problem i need to solve is how to play it only when i drag and stop it when dropped.

Flux
  • 1

1 Answers1

0

You need a view to play the animation on, so its better to make a view in your layout view hierarchy and apply the animation on it like below. hope this will help you.

image.setBackgroundResource(R.anim.cubicfacetween);
AnimationDrawable animationDrawable = (AnimationDrawable) image.getBackground();
animationDrawable.start();
Ayoub
  • 493
  • 3
  • 8