rotate每个旋转周期后会有停顿,怎么解决?

武宣凌风 2015-12-30 10:46:16
如题,todegree设置成无限大的解决方案就算了
...全文
1727 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
爬悬梯的人 2017-04-14
  • 打赏
  • 举报
回复
代码中设置匀速转动,LinearInterpolator lir = new LinearInterpolator(); rotate.setInterpolator(lir); img_load_animation.startAnimation(rotate); xml文件中去掉android:repeatMode这个属性就好了,亲测可行
爬悬梯的人 2017-04-12
  • 打赏
  • 举报
回复
直接去掉android:repeatMode这个属性就好了,亲测可行
XXXJ_feng 2016-07-18
  • 打赏
  • 举报
回复
setInterpolator(new LinearInterpolator()); 给个匀速插值器就OK了
jklwan 2016-01-04
  • 打赏
  • 举报
回复
引用 3 楼 qq_32304333 的回复:

<set xmlns:android="http://schemas.android.com/apk/res/android">
    自定义动画
 <rotate
        android:duration="60000"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="21600" 
        android:repeatCount="0"/>
</set>
改成这样的

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <!--自定义动画-->
    <rotate
        android:duration="1000"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="359"
        android:repeatCount="-1"/>
</set>
repeatCount等于-1就代表无限循环,至于你说的停顿是因为默认动画效果是先慢中间速度快最后又慢速,需要设置匀速动画,需要在代码中设置

        LinearInterpolator lir = new LinearInterpolator();
        rotate.setInterpolator(lir);
        img_load_animation.startAnimation(rotate);
武宣凌风 2015-12-31
  • 打赏
  • 举报
回复
引用 1 楼 jklwan 的回复:
发你的代码看看
java代码 public class MainActivity extends Activity { ImageView img_load_animation; Animation rotate; Handler mhandler; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); img_load_animation=(ImageView) findViewById(R.id.img_load_animation); rotate=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.load); img_load_animation.startAnimation(rotate); } } <set xmlns:android="http://schemas.android.com/apk/res/android"> 自定义动画 <rotate android:duration="60000" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:toDegrees="21600" android:repeatCount="0"/> </set>
武宣凌风 2015-12-31
  • 打赏
  • 举报
回复

java代码
public class MainActivity extends Activity {
	ImageView img_load_animation;
	Animation rotate;
	Handler mhandler;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		img_load_animation=(ImageView) findViewById(R.id.img_load_animation);
		rotate=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.load);
		img_load_animation.startAnimation(rotate);
}
}

[code=xml <set xmlns:android="http://schemas.android.com/apk/res/android"> 自定义动画 <rotate android:duration="60000" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:toDegrees="21600" android:repeatCount="0"/> </set> ][/code]
jklwan 2015-12-30
  • 打赏
  • 举报
回复
发你的代码看看

80,360

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧