【问题标题】:Rotation animation in xml doesn't rotate on the middlexml中的旋转动画不会在中间旋转
【发布时间】:2012-03-13 12:35:00
【问题描述】:

这是我在 xml 中的动画,我尝试使用 android:pivotX="50%" 但仍然没有得到我想要的。旋转点是错误的。我希望绿线围绕屏幕中间旋转。

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0" android:interpolator="@android:anim/linear_interpolator"
    android:toDegrees="360" android:pivotX="0%" android:pivotY="0%"
    android:repeatCount="5"
    android:duration="5000" android:startOffset="0" />

我想做这样的动画: 绿线应该旋转,旋转点应该是屏幕的中心。我该怎么做?

【问题讨论】:

标签: android android-ui android-gui


【解决方案1】:

使用 RotateAnimation,将轴心点设置为图像的中心。

RotateAnimation anim = new RotateAnimation(0f, 350f, 15f, 15f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(700);

// Start animating the image
final ImageView splash = (ImageView) findViewById(R.id.splash);
splash.startAnimation(anim);

// Later.. stop the animation
splash.setAnimation(null);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多