ValueAnimator API 介绍
public class ValueAnimator
extends Animator 继承Animator
java.lang.Object | ||
↳ | android.animation.Animator | |
↳ | android.animation.ValueAnimator |
Known direct subclasses 直接子类
ObjectAnimator, TimeAnimator
|
这个类为正在运行的动画提供了简单的计时引擎,正在运行的动画计算动画的值并且将它设置在目标对象。
所有动画都使用一个计时脉冲,它运行在自定义的handler去确保属性的改变放生在UI线程。
默认情况下,ValueAnimator 使用非线性时间插入器,通过AccelerateDecelerateInterpolator类,此类加速进入动画并且减速退出动画,这个行为通过调用setInterpolator(TimeInterpolator)来改变。
Animators can be created from either code or resource files. Here is an example of a ValueAnimator resource file:
动画可以通过代码或者资源文件创建。一下是一个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 资源标签去创建多步动画。注意你可以定义明确的小数值(从0到1)为每一个
keyframe 去决定何时动画应该到达那个值。当然,你可以停止小数而keyframes 会被均匀地分配在整个过程。
<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 总结
Nested classes 嵌套的类 |
|
---|---|
interface
|
ValueAnimator.AnimatorUpdateListener
Implementors of this interface can add themselves as update listeners to an 实现这个接口可以将它们自己添加为对ValueAnimator实例更新监听,去接收在每一动画帧的回调,这是发生在当前ValueAnimator帧的值被计算之后。 |
Constants |
|
---|---|
int
|
INFINITE
This value used used with the 这个值用在 |
int
|
RESTART
When the animation reaches the end and 当动画结束并且 |
int
|
REVERSE
When the animation reaches the end and 当动画结束并且 |
Inherited constants 继承类 |
---|
From class
android.animation.Animator
|
Public constructors 公共构造器 |
|
---|---|
ValueAnimator()
Creates a new ValueAnimator object. 创建一个新ValueAnimator 对象 |
Public methods |
|
---|---|
void
|
addUpdateListener(ValueAnimator.AnimatorUpdateListener listener)
Adds a listener to the set of listeners that are sent update events through the life of an animation. 添加一个监听器到监听器的集合,这个集合在整个动画生命周期被发送更新时间 |
static boolean
|
areAnimatorsEnabled()
Returns whether animators are currently enabled, system-wide. 返回是否动画当前可操作的 |
void
|
cancel()
Cancels the animation. 取消动画 |
ValueAnimator
|
clone()
Creates and returns a copy of this object. 创建并返回这个对象的副本 |
void
|
end()
Ends the animation. 结束动画 |
float
|
getAnimatedFraction()
Returns the current animation fraction, which is the elapsed/interpolated fraction used in the most recent frame update on the animation. |
Object
|
getAnimatedValue()
The most recent value calculated by this
|
Object
|
getAnimatedValue(String propertyName)
The most recent value calculated by this 获取propertyName 对应的 |
long
|
getCurrentPlayTime()
Gets the current position of the animation in time, which is equal to the current time minus the time that the animation started. 及时获取当前动画的位置,相当于当前时间减去开始时间 |
long
|
getDuration()
Gets the length of the animation. 获取动画的时长 |
static long
|
getFrameDelay()
The amount of time, in milliseconds, between each frame of the animation. 动画的帧与帧之间时间的总量,毫秒 |
TimeInterpolator
|
getInterpolator()
Returns the timing interpolator that this ValueAnimator uses. 返回ValueAnimator使用的时间差之器 |
int
|
getRepeatCount()
Defines how many times the animation should repeat. 返回动画应该重复的次数 |
int
|
getRepeatMode()
Defines what this animation should do when it reaches the end. 返回动画结束时动画应该做什么 |
long
|
getStartDelay()
The amount of time, in milliseconds, to delay starting the animation after
|
long
|
getTotalDuration()
Gets the total duration of the animation, accounting for animation sequences, start delay, and repeating. 获取动画持续的时间总量,包括顺序,开始延时和重复 |
PropertyValuesHolder[]
|
getValues()
Returns the values that this ValueAnimator animates between. 返回ValueAnimator 所执行在值。 |
boolean
|
isRunning()
Returns whether this Animator is currently running (having been started and gone past any initial startDelay period and not yet ended). 返回动画是否在执行。 |
boolean
|
isStarted()
Returns whether this Animator has been started and not yet ended. 返回是否动画开始并且还没结束 |
static ValueAnimator
|
ofArgb(int... values)
Constructs and returns a ValueAnimator that animates between color values. 构造并返回一个执行在颜色之间的ValueAnimator |
static ValueAnimator
|
ofFloat(float... values)
Constructs and returns a ValueAnimator that animates between float values. 构造并返回一个执行在floate值之间的ValueAnimator |
static ValueAnimator
|
ofInt(int... values)
Constructs and returns a ValueAnimator that animates between int values. 构造并返回一个执行在int值之间的ValueAnimator |
static ValueAnimator
|
ofObject(TypeEvaluator evaluator, Object... values)
Constructs and returns a ValueAnimator that animates between Object values. 构造并返回一个执行在Object 值之间的ValueAnimator |
static ValueAnimator
|
ofPropertyValuesHolder(PropertyValuesHolder... values)
Constructs and returns a ValueAnimator that animates between the values specified in the PropertyValuesHolder objects. 构造并返回一个执行在定义在PropertyValuesHolder值之间的ValueAnimator |
void
|
pause()
Pauses a running animation. 暂停动画 |
void
|
removeAllUpdateListeners()
Removes all listeners from the set listening to frame updates for this animation. 清除所有更新监听 |
void
|
removeUpdateListener(ValueAnimator.AnimatorUpdateListener listener)
Removes a listener from the set listening to frame updates for this animation. 清除集合中的指定监听 |
void
|
resume()
Resumes a paused animation, causing the animator to pick up where it left off when it was paused. 使暂停的动画获取焦点 |
void
|
reverse()
Plays the ValueAnimator in reverse. 反向执行动画 |
void
|
setCurrentFraction(float fraction)
Sets the position of the animation to the specified fraction. 设置动画的位置到指定的小数值 |
void
|
setCurrentPlayTime(long playTime)
Sets the position of the animation to the specified point in time. 设置动画的位置到指定的时间点 |
ValueAnimator
|
setDuration(long duration)
Sets the length of the animation. 设置动画执行的时长 |
void
|
setEvaluator(TypeEvaluator value)
The type evaluator to be used when calculating the animated values of this animation. 类型估值器用在计算动画执行值时 |
void
|
setFloatValues(float... values)
Sets float values that will be animated between. 设置动画执行的值 |
static void
|
setFrameDelay(long frameDelay)
The amount of time, in milliseconds, between each frame of the animation. 帧与帧之间的时长 |
void
|
setIntValues(int... values)
Sets int values that will be animated between. 设置动画执行的值 |
void
|
setInterpolator(TimeInterpolator value)
The time interpolator used in calculating the elapsed fraction of this animation. 设置时间差值器 |
void
|
setObjectValues(Object... values)
Sets the values to animate between for this animation. |
void
|
setRepeatCount(int value)
Sets how many times the animation should be repeated. 设置重复次数 |
void
|
setRepeatMode(int value)
Defines what this animation should do when it reaches the end. 设置动画结束时的动作 |
void
|
setStartDelay(long startDelay)
The amount of time, in milliseconds, to delay starting the animation after 设置开始延时 |
void
|
setValues(PropertyValuesHolder... values)
Sets the values, per property, being animated between. |
void
|
start()
Starts this animation. |
String
|
toString()
Returns a string representation of the object. |
Inherited methods |
|
---|---|
From class
android.animation.Animator
|
|
From class
java.lang.Object
|
ValueAnimator API 介绍相关推荐
- Android 属性动画(Property Animation) ValueAnimator 的介绍
先说下属性动画与视图动画的区别: 视图动画系统仅提供为 View 对象添加动画效果的功能,因此,如果您想为非 对象添加动画效果,则必须实现自己的代码才能做到.视图动画系统也存在一些限制,因为它仅公开 ...
- HTML5 Audio标签方法和函数API介绍
问说网 > 文章教程 > 网页制作 > HTML5 Audio标签方法和函数API介绍 Audio APIHTML5HTML5 Audio预加载 HTML5 Audio标签方法和函 ...
- Servlet基础(一) Servlet基础和关键的API介绍
转载:http://www.cnblogs.com/mengdd/p/3202550.html Servlet基础(一) Servlet简介 关键API介绍及结合源码讲解 Servlet基础(一) S ...
- Socket基础API介绍
文章目录 1 Socket基础API介绍 1 Socket基础API介绍 我们先来看下使用Socket API建立简易TCP服务端和客户端的步骤: 用Socket API建立简易TCP服务端: 建立一 ...
- 学习笔记Hadoop(十四)—— MapReduce开发入门(2)—— MapReduce API介绍、MapReduce实例
四.MapReduce API介绍 一般MapReduce都是由Mapper, Reducer 及main 函数组成. Mapper程序一般完成键值对映射操作; Reducer 程序一般完成键值对聚合 ...
- TEE Internal core API介绍(globalplatform)
目录 一.TEE的API介绍 1.Cryptographic Operations API 加解密函数介绍() (1).Generic Operation Functions TEE_Allocate ...
- Globalplatform TEE api介绍
文章目录 1.TEE API介绍 2.Client API : CA与TA通信的API介绍 3.TEE API : TA系统调用TEE OS的API (1).Asymmetric (2).Authen ...
- 组合筛选vue_Vue 3 组合式API介绍
组合式API介绍 通过创建 Vue 组件,我们可以将接口的可重复部分及其功能提取到可重用的代码段中.仅此一项就可以使我们的应用程序在可维护性和灵活性方面走得更远.然而,我们的经验已经证明,光靠这一点可 ...
- 科大讯飞cordova语音插件填坑及api介绍
项目要求语音合成,准备调用科大讯飞的cordova插件,百度仅有一篇有价值的参考文章(再吐槽下,百度搜索到各种复制的文章....),谷歌有2篇,但介绍不全,只用typescript列出api,没有ap ...
最新文章
- 脑洞:如果地府需要一个后台管理系统,你会如何设计?
- 【干货】功能堆砌or视觉美观?看优秀PM如何权衡
- linux-Centos7安装python3并与python2共存
- apple tv 开发_如何跨多台Apple TV同步Apple TV的主屏幕
- P2680-运输计划【LCA,树上差分,二分答案】
- 作为服务器上的操作系统,作为服务器的操作系统
- js遍历 for-of
- ad电阻原理图_负载电阻的原理及应用
- 大话数据结构顺序表和链表
- android view setleft,android – 在新textview上使用setLeft / setRight方法
- Java I/O系统之InputStream
- cadence元件编号更新_OrCAD教程:如何对元件进行替换与更新
- kux格式怎么转换成mp3_优酷kux1080转码工具 1080p kux格式转换mp4|优酷kux格式转换成MP4格式...
- d2crub学习2 算合计
- oracle 调整shared pool,Oracle设置Shared Pool的大小
- 用python把图片换成蓝底_详解Python给照片换底色(蓝底换红底)
- jupyter notebook如何自动生成目录(extensions)
- Go实战--golang中使用JWT(JSON Web Token)
- 调用模板类出现undefined reference to的情况及解决方案
- 一个人的赛道——天数智芯在AI计算领域的突围
热门文章
- 给正在为就业苦恼的应届生
- 解答MPLS基础的路由问题—Vecloud微云
- 【SmartJob】【隔离】每天定时掉线问题解决:隔离定期重启脚本更新
- 1086 就不告诉你
- 影响JavaScript应用可扩展性因素
- Jquery学习笔记:利用find和children方法获取后代元素
- struts2 ajax请求发现执行action两次原因
- 执行目标文件引发的问题:syntax error: word unexpected (expe...
- Walking on the path of Redis --- Redis configuration
- 通过Web Service获取天气预报并朗读