最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實(shí)現(xiàn)簡單旋轉(zhuǎn)動畫

 更新時間:2022年07月20日 10:02:45   作者:Android-kongqw  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)簡單旋轉(zhuǎn)動畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android實(shí)現(xiàn)簡單旋轉(zhuǎn)動畫的具體代碼,供大家參考,具體內(nèi)容如下

核心方法

public void startAnimation(Animation animation)

執(zhí)行動畫,參數(shù)可以是各種動畫的對象,Animation的多態(tài),也可以是組合動畫,后面會有。

2個參數(shù)的構(gòu)造方法

/**
?* Constructor to use when building a RotateAnimation from code.
?* Default pivotX/pivotY point is (0,0).
?*?
?* @param fromDegrees Rotation offset to apply at the start of the animation.
?* @param toDegrees Rotation offset to apply at the end of the animation.
?*/
public RotateAnimation(float fromDegrees, float toDegrees) {
? ? mFromDegrees = fromDegrees;
? ? mToDegrees = toDegrees;
? ? mPivotX = 0.0f;
? ? mPivotY = 0.0f;
}
  • 第一個參數(shù)是圖片旋轉(zhuǎn)的起始度數(shù)
  • 第二個參數(shù)是圖片旋轉(zhuǎn)結(jié)束的度數(shù)

用法

RotateAnimation ta = new RotateAnimation(0, 360);
// 設(shè)置動畫播放的時間
ta.setDuration(1000);
// 開始播放動畫
iv.startAnimation(ta);

效果

以圖片左上角為旋轉(zhuǎn)中心,順時針旋轉(zhuǎn)360度

4個參數(shù)的構(gòu)造方法

/**
? ? ?* Constructor to use when building a RotateAnimation from code
? ? ?*?
? ? ?* @param fromDegrees Rotation offset to apply at the start of the animation.
? ? ?* @param toDegrees Rotation offset to apply at the end of the animation.
? ? ?* @param pivotX The X coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the left edge.
? ? ?* @param pivotY The Y coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the top edge.
? ? ?*/
? ? public RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY) {
? ? ? ? mFromDegrees = fromDegrees;
? ? ? ? mToDegrees = toDegrees;

? ? ? ? mPivotXType = ABSOLUTE;
? ? ? ? mPivotYType = ABSOLUTE;
? ? ? ? mPivotXValue = pivotX;
? ? ? ? mPivotYValue = pivotY;
? ? ? ? initializePivotPoint();
? ? }
  • 頭兩個參數(shù)和上面兩個參數(shù)的構(gòu)造方法一樣,是開始和結(jié)束的角度
  • 后兩個參數(shù)是設(shè)置圖片的旋轉(zhuǎn)中心

用法

RotateAnimation ta = new RotateAnimation(0, 360, iv.getWidth() / 2, iv.getHeight() / 2);
// 設(shè)置動畫播放的時間
ta.setDuration(1000);
// 開始播放動畫
iv.startAnimation(ta);

效果

以圖片中心為旋轉(zhuǎn)中心,順時針旋轉(zhuǎn)360度

6個參數(shù)的構(gòu)造方法

/**
* Constructor to use when building a RotateAnimation from code
*?
* @param fromDegrees Rotation offset to apply at the start of the animation.
* @param toDegrees Rotation offset to apply at the end of the animation.
* @param pivotXType Specifies how pivotXValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.
* @param pivotXValue The X coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the left edge. This value can either be an absolute number if pivotXType is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.
* @param pivotYType Specifies how pivotYValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.
* @param pivotYValue The Y coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the top edge. This value can either be an absolute number if pivotYType is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.
*/
public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) {
? ?mFromDegrees = fromDegrees;
? ?mToDegrees = toDegrees;

? ?mPivotXValue = pivotXValue;
? ?mPivotXType = pivotXType;
? ?mPivotYValue = pivotYValue;
? ?mPivotYType = pivotYType;
? ?initializePivotPoint();
}

比4個參數(shù)的構(gòu)造方法多了第三個和第五個參數(shù),其他用法一樣,第三個和四五個參數(shù)分別設(shè)置第四個和第六個參數(shù)的類型,四個參數(shù)的構(gòu)造沒有設(shè)置,是默認(rèn)設(shè)置了Animation.ABSOLUTE類型

用法

// 創(chuàng)建旋轉(zhuǎn)的動畫對象
RotateAnimation ta = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
// 設(shè)置動畫播放的時間
ta.setDuration(1000);
// 開始播放動畫
iv.startAnimation(ta);

效果

和上面一樣,以圖片中心為旋轉(zhuǎn)中心,順時針旋轉(zhuǎn)360度。

設(shè)置動畫重復(fù)播放的次數(shù)的方法

/**
?* Sets how many times the animation should be repeated. If the repeat
?* count is 0, the animation is never repeated. If the repeat count is
?* greater than 0 or {@link #INFINITE}, the repeat mode will be taken
?* into account. The repeat count is 0 by default.
?*
?* @param repeatCount the number of times the animation should be repeated
?* @attr ref android.R.styleable#Animation_repeatCount
?*/
public void setRepeatCount(int repeatCount) {
? ? if (repeatCount < 0) {
? ? ? ? repeatCount = INFINITE;
? ? }
? ? mRepeatCount = repeatCount;
}

使用

sa.setRepeatCount(2);

一直重復(fù)

sa.setRepeatCount(Animation.INFINITE);

設(shè)置動畫重復(fù)播放的模式的方法

/**
?* Defines what this animation should do when it reaches the end. This
?* setting is applied only when the repeat count is either greater than
?* 0 or {@link #INFINITE}. Defaults to {@link #RESTART}.?
?*
?* @param repeatMode {@link #RESTART} or {@link #REVERSE}
?* @attr ref android.R.styleable#Animation_repeatMode
?*/
public void setRepeatMode(int repeatMode) {
? ? mRepeatMode = repeatMode;
}

使用

sa.setRepeatMode(ScaleAnimation.REVERSE);

動畫的監(jiān)聽

rotateAnimation.setAnimationListener(new AnimationListener() {

? ? ? ? ? ? @Override
? ? ? ? ? ? public void onAnimationStart(Animation animation) {
? ? ? ? ? ? ? ? // TODO Auto-generated method stub

? ? ? ? ? ? }

? ? ? ? ? ? @Override
? ? ? ? ? ? public void onAnimationRepeat(Animation animation) {
? ? ? ? ? ? ? ? // TODO Auto-generated method stub

? ? ? ? ? ? }

? ? ? ? ? ? @Override
? ? ? ? ? ? public void onAnimationEnd(Animation animation) {
? ? ? ? ? ? ? ? // TODO Auto-generated method stub

? ? ? ? ? ? }
?});

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android中PathMeasure仿支付寶支付動畫

    Android中PathMeasure仿支付寶支付動畫

    這篇文章主要為大家詳細(xì)介紹了Android中PathMeasure仿支付寶支付動畫,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • RecyclerView自定義分割線

    RecyclerView自定義分割線

    這篇文章主要為大家詳細(xì)介紹了RecyclerView自定義分割線的相關(guān)資料,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-09-09
  • Android getViewById和getLayoutInflater().inflate()的詳解及比較

    Android getViewById和getLayoutInflater().inflate()的詳解及比較

    這篇文章主要介紹了Android getViewById和getLayoutInflater().inflate()的詳解及比較的相關(guān)資料,這里對這兩種方法進(jìn)行了詳細(xì)的對比,對于開始學(xué)習(xí)Android的朋友使用這兩種方法是個很好的資料,需要的朋友可以參考下
    2016-11-11
  • Android中Root權(quán)限獲取的簡單代碼

    Android中Root權(quán)限獲取的簡單代碼

    那么我們在Android開發(fā)中如何獲取Android的Root權(quán)限呢?下面是主要的簡單代碼。
    2013-06-06
  • Kotlin如何直接使用控件ID原理詳析

    Kotlin如何直接使用控件ID原理詳析

    這篇文章主要給大家介紹了關(guān)于Kotlin如何直接使用控件ID原理的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-12-12
  • 詳解Android App卸載后跳轉(zhuǎn)到指定的反饋頁面的方法

    詳解Android App卸載后跳轉(zhuǎn)到指定的反饋頁面的方法

    這篇文章主要介紹了Android App卸載后跳轉(zhuǎn)到指定的反饋頁面的方法,關(guān)鍵點(diǎn)是相關(guān)線程要判斷在目錄被消除以前作出響應(yīng),需要的朋友可以參考下
    2016-04-04
  • Android控件PullRefreshViewGroup實(shí)現(xiàn)下拉刷新和上拉加載

    Android控件PullRefreshViewGroup實(shí)現(xiàn)下拉刷新和上拉加載

    這篇文章主要為大家詳細(xì)介紹了Android控件PullRefreshViewGroup實(shí)現(xiàn)下拉刷新和上拉加載效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • 獲取Android設(shè)備電池電量狀態(tài)

    獲取Android設(shè)備電池電量狀態(tài)

    本文介紹了在Android系統(tǒng)中獲取設(shè)備電池電量狀態(tài)的方法,包括使用BatteryManager類獲取電量百分比、電池狀態(tài)和健康狀況,以及通過注冊廣播接收器實(shí)時獲取電量狀態(tài)變化。了解這些方法可以幫助用戶更好地管理設(shè)備的使用,避免因電量不足而影響使用體驗(yàn)。
    2023-03-03
  • android自定義組件實(shí)現(xiàn)儀表計數(shù)盤

    android自定義組件實(shí)現(xiàn)儀表計數(shù)盤

    這篇文章主要為大家詳細(xì)介紹了android自定義組件實(shí)現(xiàn)儀表計數(shù)盤,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-11-11
  • Android通訊錄開發(fā)之刪除功能的實(shí)現(xiàn)方法

    Android通訊錄開發(fā)之刪除功能的實(shí)現(xiàn)方法

    這篇文章主要介紹了Android通訊錄開發(fā)之刪除功能的實(shí)現(xiàn)方法,有需要的朋友可以參考一下
    2014-01-01

最新評論

德庆县| 青田县| 闻喜县| 天等县| 广平县| 钟山县| 永昌县| 简阳市| 通榆县| 铜梁县| 尼勒克县| 三明市| 石泉县| 曲沃县| 临夏市| 额敏县| 花莲县| 肇庆市| 蒙阴县| 军事| 台安县| 精河县| 驻马店市| 吉木乃县| 左权县| 新河县| 区。| 五大连池市| 鲁山县| 思南县| 通州区| 深泽县| 长宁县| 永善县| 和田市| 吴桥县| 孝感市| 宣武区| 泗水县| 临泉县| 大同县|