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

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

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

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

核心方法

public void startAnimation(Animation animation)

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

2個(gè)參數(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;
}
  • 第一個(gè)參數(shù)是圖片旋轉(zhuǎn)的起始度數(shù)
  • 第二個(gè)參數(shù)是圖片旋轉(zhuǎn)結(jié)束的度數(shù)

用法

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

效果

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

4個(gè)參數(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();
? ? }
  • 頭兩個(gè)參數(shù)和上面兩個(gè)參數(shù)的構(gòu)造方法一樣,是開始和結(jié)束的角度
  • 后兩個(gè)參數(shù)是設(shè)置圖片的旋轉(zhuǎn)中心

用法

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

效果

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

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

用法

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

效果

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

設(shè)置動(dòng)畫重復(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è)置動(dòng)畫重復(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);

動(dòng)畫的監(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

? ? ? ? ? ? }
?});

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

相關(guān)文章

  • Android中PathMeasure仿支付寶支付動(dòng)畫

    Android中PathMeasure仿支付寶支付動(dòng)畫

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

    RecyclerView自定義分割線

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

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

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

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

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

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

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

    詳解Android App卸載后跳轉(zhuǎn)到指定的反饋?lái)?yè)面的方法

    這篇文章主要介紹了Android App卸載后跳轉(zhuǎn)到指定的反饋?lái)?yè)面的方法,關(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)下拉刷新和上拉加載效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • 獲取Android設(shè)備電池電量狀態(tài)

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

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

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

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

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

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

最新評(píng)論

台前县| 保靖县| 孙吴县| 新安县| 晋城| 雷州市| 长宁县| 乳山市| 合山市| 郯城县| 赣州市| 抚顺市| 迭部县| 奉节县| 寿光市| 玉龙| 南宁市| 淳安县| 元朗区| 伊川县| 高尔夫| 天柱县| 扬中市| 曲靖市| 文水县| 洪江市| 克山县| 茶陵县| 永宁县| 富裕县| 襄樊市| 江孜县| 调兵山市| 嵩明县| 阿拉善右旗| 静安区| 南溪县| 元谋县| 板桥市| 通河县| 星子县|