博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android_属性动画
阅读量:4290 次
发布时间:2019-05-27

本文共 2685 字,大约阅读时间需要 8 分钟。

属性动画
// Added in API level 11
public abstract class Animator extends Object implements Cloneable{}
//Known Direct Subclasses 
AnimatorSet
ValueAnimator
//Known Indirect Subclasses 
ObjectAnimator
TimeAnimator
//Animator的方法
addListener(Animator.AnimatorListener listener);
isPaused(); isRunning(); isStarted();
Animator clone();
start();
end();
cancel();
resume();
setDuration(long duration);
setStartDelay(long startDelay);
setTarget(Object target);
ObjectAnimator:
ObjectAnimator.ofFloat(Object target, String propertyName, float... values);
ObjectAnimator.ofInt(Object target, String propertyName, int... values);
ObjectAnimator.ofObject(T target, Property<T, V> property, TypeEvaluator<V> evaluator, V... values);
setFloatValues(float... values);
setIntValues(int... values);
setPropertyName(String propertyName);
setTarget(Object target);
//ObjectAnimator()  逐个添加参数
ValueAnimator:
//a simple timing engine for running animations which calculate animated values and set them on target objects
AnimatorSet:
playSequentially(List<Animator> items);
play(Animator anim);
playTogether(Animator... items);
playSequentially(Animator... items);
ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "translationY", 10, 50,20,150);
ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "scaleY", 1, 2, 1, 2,3,5,1);
ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "alpha", 0, 0.5f, 0, 1,0,1,0,0);
ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "rotationX", 0, 180, 90, 360);
AnimatorSet as = new AnimatorSet();
ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "translationX", 10, 50, 20, 100);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(iv, "scaleY", 0.1f, 2, 1, 2);
ObjectAnimator oa3 = ObjectAnimator.ofFloat(iv, "alpha", 0, 0.5f, 0, 1);
ObjectAnimator oa4 = ObjectAnimator.ofFloat(iv, "rotationY", 0, 180, 90, 360);
as.setDuration(2000);
as.setTarget(iv);
as.playSequentially(oa, oa2, oa3, oa4);
//往集合中添加动画
//挨个飞
as.playTogether(oa, oa2, oa3, oa4);
//一起飞
as.start();
xml
/res/animator/^^.xml
AnimatorInflater:
static Animator  loadAnimator(Context context, int id) ;
<set xmlns:android="http://schemas.android.com/apk/res/android" >
    <objectAnimator 
        android:propertyName="translationX"
//backgroundColor
        android:duration="2000"
        android:valueFrom="10"
        android:valueTo="100"
        android:startOffset="int"
        android:repeatCount="int"
        android:repeatMode="reverse"
        android:valueType=""/>
    <animator
     
android:duration=""
     
android:valueFrom=""
     
android:valueTo=""
     
android:repeatCount=""
     
android:repeatMode=""
     
android:interpolator=""
     
android:valueType=""
     
/>
</set>
//代码示例
ObjectAnimator colorAnim = (ObjectAnimator)AnimatorInflater.loadAnimator(MainActivity.this,R.animator.color_anim);
color.setTarget(this);
colorAnim.start();

转载地址:http://ibegi.baihongyu.com/

你可能感兴趣的文章
Android大图片处理
查看>>
Hadoop平台相关技术
查看>>
Android中热修复框架AndFix原理解析及案例使用
查看>>
手写代码实现EventBus
查看>>
关于JSON的相关知识
查看>>
SpringMVC基础_常用注解
查看>>
Spring框架-IOC容器和Bean的配置(1)
查看>>
查询内容在网页里面分页显示+跳页查看
查看>>
mysql substring函数截取值后赋给一个declare变量
查看>>
Java Thread 的 sleep() 和 wait() 的区别
查看>>
DbUtils入门
查看>>
每一个程序员需要了解的10个Linux命令
查看>>
service的自调用 VS service之间调用
查看>>
Android权限管理之Permission权限机制及使用
查看>>
重识Retrofit
查看>>
PowerDesigner(数据建模)使用大全
查看>>
RadioButton与CheckBox_优就业
查看>>
java中的throw与throws的区别
查看>>
优化用户登录体验效果
查看>>
用js批量选中功能实现更改数据库中status状态值_优就业
查看>>