手头的问题:
我目前正在尝试为刷新图标编写动画功能,到目前为止,通过研究我只能设法获取此代码段:
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。
答案 0 :(得分:1)
我猜你需要像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);
希望这有帮助。