日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

ValueAnimator API 介绍

發(fā)布時(shí)間:2025/4/16 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ValueAnimator API 介绍 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

public class ValueAnimator?
extends?Animator?繼承Animator

java.lang.Object
????android.animation.Animator
?????android.animation.ValueAnimator
Known direct subclasses? ?直接子類ObjectAnimator,?TimeAnimator

這個(gè)類為正在運(yùn)行的動(dòng)畫提供了簡(jiǎn)單的計(jì)時(shí)引擎,正在運(yùn)行的動(dòng)畫計(jì)算動(dòng)畫的值并且將它設(shè)置在目標(biāo)對(duì)象。

所有動(dòng)畫都使用一個(gè)計(jì)時(shí)脈沖,它運(yùn)行在自定義的handler去確保屬性的改變放生在UI線程。

默認(rèn)情況下,ValueAnimator 使用非線性時(shí)間插入器,通過AccelerateDecelerateInterpolator類,此類加速進(jìn)入動(dòng)畫并且減速退出動(dòng)畫,這個(gè)行為通過調(diào)用setInterpolator(TimeInterpolator)來改變。


Animators can be created from either code or resource files. Here is an example of a ValueAnimator resource file:

動(dòng)畫可以通過代碼或者資源文件創(chuàng)建。一下是一個(gè)ValueAnimator 資源文件的例子。

<animator xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1000" android:valueFrom="1" android:valueTo="0" android:valueType="floatType" android:repeatCount="1" android:repeatMode="reverse"/>


從API23開始,同樣可以用PropertyValuesHolder?和Keyframe?資源標(biāo)簽去創(chuàng)建多步動(dòng)畫。注意你可以定義明確的小數(shù)值(從0到1)為每一個(gè)?keyframe 去決定何時(shí)動(dòng)畫應(yīng)該到達(dá)那個(gè)值。當(dāng)然,你可以停止小數(shù)而keyframes 會(huì)被均勻地分配在整個(gè)過程。


<animator xmlns:android="http://schemas.android.com/apk/res/android"android:duration="1000"android:repeatCount="1"android:repeatMode="reverse"><propertyValuesHolder><keyframe android:fraction="0" android:value="1"/><keyframe android:fraction=".2" android:value=".4"/><keyframe android:fraction="1" android:value="0"/></propertyValuesHolder> </animator>


Summary? 總結(jié)

Nested classes? ? ? ? 嵌套的類

interfaceValueAnimator.AnimatorUpdateListener

Implementors of this interface can add themselves as update listeners to an?ValueAnimatorinstance to receive callbacks on every animation frame, after the current frame's values have been calculated for that?ValueAnimator.?

實(shí)現(xiàn)這個(gè)接口可以將它們自己添加為對(duì)ValueAnimator實(shí)例更新監(jiān)聽,去接收在每一動(dòng)畫的回調(diào),這是發(fā)生在當(dāng)前ValueAnimator幀的值被計(jì)算之后。

Constants

intINFINITE

This value used used with the?setRepeatCount(int)?property to repeat the animation indefinitely.

這個(gè)值用在setRepeatCount(int)?屬性去無限重復(fù)動(dòng)畫。

intRESTART

When the animation reaches the end and?repeatCount?is INFINITE or a positive value, the animation restarts from the beginning.

當(dāng)動(dòng)畫結(jié)束并且repeatCount? 是INFINITE? ?或者一個(gè)正值時(shí),動(dòng)畫重頭開始。

intREVERSE

When the animation reaches the end and?repeatCount?is INFINITE or a positive value, the animation reverses direction on every iteration.

當(dāng)動(dòng)畫結(jié)束并且repeatCount? 是INFINITE? ?或者一個(gè)正值時(shí),動(dòng)畫在每個(gè)迭代取反方向

Inherited constants? 繼承類

From class?android.animation.Animator

Public constructors? ?公共構(gòu)造器

ValueAnimator()

Creates a new ValueAnimator object.

創(chuàng)建一個(gè)新ValueAnimator 對(duì)象

Public methods

voidaddUpdateListener(ValueAnimator.AnimatorUpdateListener?listener)

Adds a listener to the set of listeners that are sent update events through the life of an animation.

添加一個(gè)監(jiān)聽器到監(jiān)聽器的集合,這個(gè)集合在整個(gè)動(dòng)畫生命周期被發(fā)送更新時(shí)間

static booleanareAnimatorsEnabled()

Returns whether animators are currently enabled, system-wide.

返回是否動(dòng)畫當(dāng)前可操作的

voidcancel()

Cancels the animation.

取消動(dòng)畫

ValueAnimatorclone()

Creates and returns a copy of this object.

創(chuàng)建并返回這個(gè)對(duì)象的副本

voidend()

Ends the animation.

結(jié)束動(dòng)畫

floatgetAnimatedFraction()

Returns the current animation fraction, which is the elapsed/interpolated fraction used in the most recent frame update on the animation.

ObjectgetAnimatedValue()

The most recent value calculated by this?ValueAnimator?when there is just one property being animated.

ValueAnimator?計(jì)算的最近值 當(dāng)只有一個(gè)屬性被執(zhí)行

ObjectgetAnimatedValue(String?propertyName)

The most recent value calculated by this?ValueAnimator?for?propertyName.

獲取propertyName 對(duì)應(yīng)的ValueAnimator?計(jì)算的最近的值

longgetCurrentPlayTime()

Gets the current position of the animation in time, which is equal to the current time minus the time that the animation started.

及時(shí)獲取當(dāng)前動(dòng)畫的位置,相當(dāng)于當(dāng)前時(shí)間減去開始時(shí)間

longgetDuration()

Gets the length of the animation.

獲取動(dòng)畫的時(shí)長(zhǎng)

static longgetFrameDelay()

The amount of time, in milliseconds, between each frame of the animation.

動(dòng)畫的幀與幀之間時(shí)間的總量,毫秒

TimeInterpolatorgetInterpolator()

Returns the timing interpolator that this ValueAnimator uses.

返回ValueAnimator使用的時(shí)間差之器

intgetRepeatCount()

Defines how many times the animation should repeat.

返回動(dòng)畫應(yīng)該重復(fù)的次數(shù)

intgetRepeatMode()

Defines what this animation should do when it reaches the end.

返回動(dòng)畫結(jié)束時(shí)動(dòng)畫應(yīng)該做什么

longgetStartDelay()

The amount of time, in milliseconds, to delay starting the animation after?start()?is called.

?start()調(diào)用之后 延時(shí)的時(shí)間總量

longgetTotalDuration()

Gets the total duration of the animation, accounting for animation sequences, start delay, and repeating.

獲取動(dòng)畫持續(xù)的時(shí)間總量,包括順序,開始延時(shí)和重復(fù)

PropertyValuesHolder[]getValues()

Returns the values that this ValueAnimator animates between.

返回ValueAnimator 所執(zhí)行在值。

booleanisRunning()

Returns whether this Animator is currently running (having been started and gone past any initial startDelay period and not yet ended).

返回動(dòng)畫是否在執(zhí)行。

booleanisStarted()

Returns whether this Animator has been started and not yet ended.

返回是否動(dòng)畫開始并且還沒結(jié)束

static?ValueAnimatorofArgb(int...?values)

Constructs and returns a ValueAnimator that animates between color values.

構(gòu)造并返回一個(gè)執(zhí)行在顏色之間的ValueAnimator?

static?ValueAnimatorofFloat(float...?values)

Constructs and returns a ValueAnimator that animates between float values.

構(gòu)造并返回一個(gè)執(zhí)行在floate值之間的ValueAnimator?

static?ValueAnimatorofInt(int...?values)

Constructs and returns a ValueAnimator that animates between int values.

構(gòu)造并返回一個(gè)執(zhí)行在int值之間的ValueAnimator?

static?ValueAnimatorofObject(TypeEvaluator?evaluator,?Object...?values)

Constructs and returns a ValueAnimator that animates between Object values.

構(gòu)造并返回一個(gè)執(zhí)行在Object?值之間的ValueAnimator?

static?ValueAnimatorofPropertyValuesHolder(PropertyValuesHolder...?values)

Constructs and returns a ValueAnimator that animates between the values specified in the PropertyValuesHolder objects.

構(gòu)造并返回一個(gè)執(zhí)行在定義在PropertyValuesHolder值之間的ValueAnimator?

voidpause()

Pauses a running animation.

暫停動(dòng)畫

voidremoveAllUpdateListeners()

Removes all listeners from the set listening to frame updates for this animation.

清除所有更新監(jiān)聽

voidremoveUpdateListener(ValueAnimator.AnimatorUpdateListener?listener)

Removes a listener from the set listening to frame updates for this animation.

清除集合中的指定監(jiān)聽

voidresume()

Resumes a paused animation, causing the animator to pick up where it left off when it was paused.

使暫停的動(dòng)畫獲取焦點(diǎn)

voidreverse()

Plays the ValueAnimator in reverse.

反向執(zhí)行動(dòng)畫

voidsetCurrentFraction(float fraction)

Sets the position of the animation to the specified fraction.

設(shè)置動(dòng)畫的位置到指定的小數(shù)值

voidsetCurrentPlayTime(long playTime)

Sets the position of the animation to the specified point in time.

設(shè)置動(dòng)畫的位置到指定的時(shí)間點(diǎn)

ValueAnimatorsetDuration(long duration)

Sets the length of the animation.

設(shè)置動(dòng)畫執(zhí)行的時(shí)長(zhǎng)

voidsetEvaluator(TypeEvaluator?value)

The type evaluator to be used when calculating the animated values of this animation.

類型估值器用在計(jì)算動(dòng)畫執(zhí)行值時(shí)

voidsetFloatValues(float...?values)

Sets float values that will be animated between.

設(shè)置動(dòng)畫執(zhí)行的值

static voidsetFrameDelay(long frameDelay)

The amount of time, in milliseconds, between each frame of the animation.

幀與幀之間的時(shí)長(zhǎng)

voidsetIntValues(int...?values)

Sets int values that will be animated between.

設(shè)置動(dòng)畫執(zhí)行的值

voidsetInterpolator(TimeInterpolator?value)

The time interpolator used in calculating the elapsed fraction of this animation.

設(shè)置時(shí)間差值器

voidsetObjectValues(Object...?values)

Sets the values to animate between for this animation.

voidsetRepeatCount(int value)

Sets how many times the animation should be repeated.

設(shè)置重復(fù)次數(shù)

voidsetRepeatMode(int value)

Defines what this animation should do when it reaches the end.

設(shè)置動(dòng)畫結(jié)束時(shí)的動(dòng)作

voidsetStartDelay(long startDelay)

The amount of time, in milliseconds, to delay starting the animation after?start()?is called.

設(shè)置開始延時(shí)

voidsetValues(PropertyValuesHolder...?values)

Sets the values, per property, being animated between.

voidstart()

Starts this animation.

StringtoString()

Returns a string representation of the object.

Inherited methods

From class?android.animation.Animator
From class?java.lang.Object



總結(jié)

以上是生活随笔為你收集整理的ValueAnimator API 介绍的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。