gpt4 book ai didi

android - 如何为刷新图标编写动画代码

转载 作者:行者123 更新时间:2023-11-29 21:02:15 25 4
gpt4 key购买 nike

手头的问题:

我目前正在尝试为刷新图标编写一个动画功能,到目前为止,通过研究我只成功地找到了这个代码 fragment :

 LayoutInflater inflater= (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ImageView iv= (ImageView) inflater.inflate(R.layout.spin_refresh, null);
Animation rotation= AnimationUtils.loadAnimation(DownloadService.this,R.anim.accelerate_decelerate_interpolator);
rotation.setRepeatCount(Animation.INFINITE);
iv.startAnimation(rotation);
refreshItem.setActionView(iv);
//TODO trigger loading

我实际上无法完全理解编码,是否有任何更简单的动画编码方式或代码本身的一般含义是什么。我已经在 res 文件夹的动画文件夹中创建了一个单独的 animation.xml。

最佳答案

我想你需要将图像旋转到自己喜欢 second animation in this post

你可以使用这个:

image.clearAnimation();
RotateAnimation anim = new RotateAnimation(30, 360, image.getWidth()/2, image.getHeight()/2);
anim.setFillAfter(true);
anim.setRepeatCount(0);
anim.setDuration(10000);
image.startAnimation(anim);

希望这对您有所帮助。

关于android - 如何为刷新图标编写动画代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25718765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com