且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

简单ImageView的旋转

更新时间:2023-02-02 14:59:35

试试这个。它为我工作。

Try this one. it work for me.

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator" >

  <rotate
      android:duration="2000"
      android:fromDegrees="0"
      android:pivotX="50%"
      android:pivotY="50%"
      android:toDegrees="360" >
  </rotate>

</set>

保存资源文件名为文件夹下的动画。

Save this file in resources under a folder named "anim".

RES /动画/ rotate.xml

res/anim/rotate.xml

在您的活动。收藏此code。

Within your activity. Add this code.

    Animation sampleFadeAnimation = AnimationUtils.loadAnimation(PreviewImageActivity.this,R.anim.rotate);
    sampleFadeAnimation.setRepeatCount(1);
    yourImageView.startAnimation(sampleFadeAnimation);

做一些研究,你会得到很多的属性,以改善这个旋转动画作为你的愿望。

Do some research you will get lot of properties to improve this rotate animation as your wish.

感谢...