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