百度了一下補間動畫的旋轉動畫,發現都是繞自身做圓周運動的,根本就不符合自己的項目需求:繞父控件的中點做圓周運動。後來隻能去其他地方查資料,實作自己想要的效果,其實實作起來很簡單,下面上代碼:
private void rotateAnimation(){;
RotateAnimation rotate = new RotateAnimation(0f,360f,RotateAnimation.RELATIVE_TO_SELF,0.5f,
RotateAnimation.RELATIVE_TO_PARENT,0.5f);
rotate.setInterpolator(new LinearInterpolator());
rotate.setDuration(10000);
rotate.setRepeatCount(0);
img_point.startAnimation(rotate);
}
就是x軸和y軸的坐标點參照的對象RotateAnimation.RELATIVE_TO_SELF和RotateAnimation.RELATIVE_TO_PAREN;
其實一開始我的x軸和y軸設定的參照對象都是RotateAnimation.RELATIVE_TO_PAREN,發現并不是以父控件的中心旋轉,隻有把
x軸的參照對象改為RotateAnimation.RELATIVE_TO_SELF才可以染中點旋轉。
不知道為什麼要這麼改,求有知道的大神告知