RotateAnimation 详解
2019獨角獸企業重金招聘Python工程師標準>>>
(轉)Android RotateAnimation詳解
其他構造器的旋轉也可參考這副圖。
RotateAnimation旋轉坐標系為以旋轉點為坐標系(0,0)點。x軸為0度,順時針方向旋轉一定的角度。
1.RotateAnimation(fromDegrees,?toDegrees)?[默認以View左上角頂點為旋轉點]。
X軸順時針轉動到fromDegrees為旋轉的起始點,
X軸順時針轉動到toDegrees為旋轉的起始點。
如fromDegrees=0,toDegrees=90;為左上角頂點為旋轉點。0度為起始點,90度為終點。進行旋轉,旋轉了90度
如fromDegrees=60,toDegrees=90;為左上角頂點為旋轉點。60度為起始點,90度為終點。進行旋轉,旋轉了90-60=30度
2.RotateAnimation(float?fromDegrees,?float?toDegrees,?float?pivotX,?float?pivotY)
(pivotX,pivotY)為旋轉點。pivotX為距離左側的偏移量,pivotY為距離頂部的偏移量。即為相對于View左上角(0,0)的坐標點。
如View?width=100px,height=100px
RotateAnimation(0,10,100,100);則以右下角頂點為旋轉點,從原始位置順時針旋轉10度
RotateAnimation(0,90,50,50);則以View的中心點為旋轉點,旋轉90度
3.RotateAnimation(fromDegrees,?toDegrees,?pivotXType,?pivotXValue,?pivotYType,?pivotYValue)
pivotXType,?pivotXValue,?pivotYType,?pivotYValue??旋轉點類型及其值。
Animation.ABSOLUTE為絕對值?其他為百分比。這個和平移動畫的一樣,不了解可以去那看
如RotateAnimation(0,?90,?Animation.RELATIVE_TO_SELF,?0.5f,?Animation.RELATIVE_TO_SELF,?0.5f);?按中心點旋轉90度
效果和2例中的RotateAnimation(0,90,50,50);則以View的中心點為旋轉點,旋轉90度?。效果一樣
new?RotateAnimation(0,?180,?centerX,centerY);
第一個參數表示動畫的起始角度,第二個參數表示動畫的結束角度,第三個表示動畫的旋轉中心x軸,第四個表示動畫旋轉中心y軸。
rotateAnimation.setDuration(1000?*?20);
表動畫持續20s。
rotateAnimation.setFillAfter(true);
ture表示動畫結束后停留在動畫的最后位置,false表示動畫結束后回到初始位置,默認為false。
mView.startAnimation(rotateAnimation);
表示在mView中啟動動畫。?
轉載于:https://my.oschina.net/u/870990/blog/141902
總結
以上是生活随笔為你收集整理的RotateAnimation 详解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ubuntu共享WiFi(AP)给And
- 下一篇: 移动界面控件Essential Stud