RotateAn = new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF,
0.5f,Animation.RELATIVE_TO_SELF,0.5f);
RotateAn.setInterpolator(new LinearInterpolator());
RotateAn.setRepeatCount(-1);
RotateAn.setFillAfter(true);
RotateAn.setDuration(4000);
shake_img.startAnimation(RotateAn);
开启动画后怎么不是以view的中心点自转 而是公转
http://www.jb51.net/article/32341.htm
在Animator中需要通过View.setPivotX和View.setPivotY方法手动给View设置中心点。
imageView.setPivotX(10);
imageView.setPivotY(10);
//是指以ImageView为坐标系(10,10)位置
我是在xml里设置的,可以阿
<?xml version="1.0" encoding="utf-8"?>
<rotate
android:duration="1000"
android:fromDegrees="0"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="+360" />
原因找到了 因为设置过View.setVisibility(View.GONE)然后再设置View.setVisibility(View.VISIBLE) 就就变成公转了 我把View隐藏设置成setVisibility(View.INVISIBLE)就不会公转。可能是设置GONE后把View的大小改变了 求哪位大神告知具体原因,谢谢