android - ImageView 中的动画旋转不流畅

标签 android animation imageview

我需要制作一个要旋转的 ImageView。为此,我使用了以下代码。

res/anim/rotator.xml:

<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/linear_interpolator">
            <rotate
            android:duration="6000"
            android:fromDegrees="0"
            android:pivotX="50%"
            android:pivotY="50%"
            android:repeatCount="1"
            android:toDegrees="359"></rotate>
    </set>

Activity.class

 final Animation myRotation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotator);
 imgSplashLogo.startAnimation(myRotation);

图像在 mycase 中旋转。
但在旋转时卡住,而不是平滑。 我的代码可能哪里出错了。

请检查。提前致谢...

最佳答案

An interpolator defines the rate of change of an animation. This allows the basic animation effects (alpha, scale, translate, rotate) to be accelerated, decelerated, repeated ;

您需要在 rotate 部分添加 android:interpolator="@android:anim/linear_interpolator"

最后

<set xmlns:android="http://schemas.android.com/apk/res/android"
   >
        <rotate
        android:duration="6000"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:repeatCount="1"
        android:toDegrees="359"
        android:interpolator="@android:anim/linear_interpolator"></rotate>
</set>

您可以使用setDrawingCacheEnabled(true);

Enabling the drawing cache is similar to setting a layer when hardware acceleration is turned off.

关于android - ImageView 中的动画旋转不流畅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35129076/

相关文章:

javascript - 在开始新动画之前清除所有使用 jquery 动画所做的更改

android - 如何在android中显示外部图像?

android - 线程卡在 WifiManager.enableNetwork()

php - 有没有办法将MySQL数据库信息下载到SQLite

android - 在Android中垂直居中 View

javascript - 元素集上的 SnapSVG 动画回调未触发

iOS:了解 UIView 上的开始动画和动画结束

java - 获取ImageView数组后面的整数

android - 在 android imageview 中使用 Glide 显示谷歌驱动器图像

android - 如何更改android中删除线的颜色?