3

I have a music app and the music notations perform an animation from right to left, I want to control the animation speed, while they are performing.Can anyone please help me for that?

My animation layout is:

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
    android:fromXDelta="500%" android:toXDelta="0%"
       android:fromYDelta="0%" android:toYDelta="0%"
       android:duration="10000" 
        android:fillAfter="true"
        android:repeatCount="infinite"/>

And my code to perform the animation is:

Animation am=AnimationUtils.loadAnimation(this, R.anim.note);
        music1.startAnimation(am);
Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
athulya k
  • 145
  • 2
  • 10

4 Answers4

4

set your android:duration with this help you can control your animation speed

android:duration="300"
Shivansh Saxena
  • 204
  • 2
  • 8
  • Not like that, Is there any way to control the speed during the animations are permorming, by touch or anything like that? – athulya k Mar 31 '14 at 07:04
1

change in the duration will control the speed of animation in your file.

  android:duration="10000" // here you have to change the time in milliseconds.
Pankaj Arora
  • 10,224
  • 2
  • 37
  • 59
0

you can implement onTouchListener to control your animation speed at the run time. inside touch listener event put coding to change your animation duration.

0

From official documentation:

ValueAnimator animation = ValueAnimator.ofFloat(0f, 100f);
animation.setDuration(1000);
animation.start()

In your case:

music.setDuration(setValue);
Mark Ezberg
  • 578
  • 1
  • 5
  • 18