Drawable Rotating around its center Android(Drawable 围绕其中心旋转 Android)
问题描述
我得到以下代码的奇怪结果:
I am getting strange results with the following code:
iv = (ImageView) findViewById(R.id.iv);
iv.setImageResource(R.drawable.spinner_white_76);
Animation a = new RotateAnimation(0.0f, 360.0f,
Animation.RELATIVE_TO_SELF, iv.getDrawable()
.getIntrinsicWidth() / 2, Animation.RELATIVE_TO_SELF,
iv.getDrawable().getIntrinsicHeight() / 2);
a.setRepeatCount(-1);
a.setDuration(1000);
iv.startAnimation(a);
指定轴点(drawable的中心)的正确方法是什么?
Whats the right way to specify the axis point (center of the drawable)?
推荐答案
觉得自己很蠢!花一些时间仔细阅读文档后让它工作:
Feel stupid! Got it to work after spending some time closely reading the documentation:
Animation a = new RotateAnimation(0.0f, 360.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
a.setRepeatCount(-1);
a.setDuration(1000);
这篇关于Drawable 围绕其中心旋转 Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!