繁体   English   中英

如何控制android中的动画速度

[英]How can I control the animation speed in android

我有一个音乐应用程序,乐谱从右到左执行动画,我想在它们执行时控制动画速度。有人可以帮我吗?

我的动画布局是:

<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"/>

我执行动画的代码是:

Animation am=AnimationUtils.loadAnimation(this, R.anim.note);
        music1.startAnimation(am);

设置你的android:duration这个帮助你可以控制你的动画速度

android:duration="300"

您可以实现onTouchListener来控制运行时的动画速度。 内部触摸监听器事件放置编码来改变您的动画持续时间。

更改持续时间将控制文件中动画的速度。

  android:duration="10000" // here you have to change the time in milliseconds.

来自官方文档

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

在你的情况下:

music.setDuration(setValue);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM