圆形头像持续旋转的使用

来源:互联网 发布:tv霸网络电视直播 编辑:程序博客网 时间:2024/06/04 19:59

实现步骤:

  1. 添加圆形头像的框架CircleImageView

  2. 在anim中添加动画属性

    <rotateandroid:duration="8000"android:fillAfter="true"android:fromDegrees="0"android:pivotX="50%"android:pivotY="50%"android:repeatCount="-1"android:repeatMode="restart"android:toDegrees="360"></rotate>
  3. 在代码中添加动画

    imageView = (CircleImageView) findViewById(R.id.imageView); animation = AnimationUtils.loadAnimation(this, R.anim.anim_round_imageview); animation.setInterpolator(new LinearInterpolator()); imageView.setAnimation(animation);
  4. 清除动画

    imageView.clearAnimation();

Noted:

  1. android:repeatCount="-1"表示不限制次数(直到过期)
  2. animation.setInterpolator(new LinearInterpolator());采用匀速的插值器

原创粉丝点击