本文介绍了如何在旋转中心点的机器人图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了下面的旋转屏幕的中心,我的图标,而是绕左上角(即原点X = 0,Y = 0的ImageView的)。它应该是简单设置的ImageView或RotateAnimation的某些属性,但我不明白。
公共类IconPromoActivity延伸活动{
私有静态最终浮动ROTATE_FROM = 0.0;
私有静态最终浮动ROTATE_TO = -10.0f * 360.0f; // 3.141592654f * 32.0f;
/ **第一次创建活动时调用。 * /
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
ImageView的图标=(ImageView的)findViewById(R.id.favicon);
RotateAnimationř; // =新RotateAnimation(ROTATE_FROM,ROTATE_TO);
R =新RotateAnimation(ROTATE_FROM,ROTATE_TO,0,0,40,0);
r.setDuration((长)2 * 1500);
r.setRepeatCount(0);
favicon.startAnimation(r)的;
}
}
解决方案
试试: R =新RotateAnimation(ROTATE_FROM,ROTATE_TO,Animation.RELATIVE_TO_SELF,0.5F,Animation.RELATIVE_TO_SELF,0.5F);
I have written the following to spin my icon on the center of the screen and instead it rotates around the upper-left corner (i.e., origin x=0, y=0 of the ImageView). It should be simple to set some attributes of the ImageView or the RotateAnimation, but I can't figure it out.
public class IconPromoActivity extends Activity {
private static final float ROTATE_FROM = 0.0f;
private static final float ROTATE_TO = -10.0f * 360.0f;// 3.141592654f * 32.0f;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView favicon = (ImageView) findViewById(R.id.favicon);
RotateAnimation r; // = new RotateAnimation(ROTATE_FROM, ROTATE_TO);
r = new RotateAnimation(ROTATE_FROM, ROTATE_TO, 0, 0, 40, 0);
r.setDuration((long) 2*1500);
r.setRepeatCount(0);
favicon.startAnimation(r);
}
}
解决方案
Try:r = new RotateAnimation(ROTATE_FROM, ROTATE_TO, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
这篇关于如何在旋转中心点的机器人图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!