美文网首页
Android动画之 PropertyValuesHolder

Android动画之 PropertyValuesHolder

作者: 附庸风雅_ | 来源:发表于2017-09-04 14:36 被阅读0次

    PropertyValuesHolder这个类可以先将动画属性和值暂时的存储起来,后一起执行,在有些时候可以使用替换掉AnimatorSet

    //keyframe
    Keyframe keyframe1 = Keyframe.ofFloat(0.0f,0);
    Keyframe keyframe2 = Keyframe.ofFloat(0.25f,-30);
    Keyframe keyframe3 = Keyframe.ofFloat(0.5f,0);
    Keyframe keyframe4 = Keyframe.ofFloat(0.75f, 30);
    Keyframe keyframe5 = Keyframe.ofFloat(1.0f,0);
    PropertyValuesHolder rotation = PropertyValuesHolder.ofKeyframe("rotation", keyframe1, keyframe2, keyframe3, keyframe4,keyframe5);
    
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha",1.0f,0.2f,1.0f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX",1.0f,0.2f,1.0f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY",1.0f,0.2f,1.0f);
    PropertyValuesHolder color = PropertyValuesHolder.ofInt("BackgroundColor", 0XFFFFFF00, 0XFF0000FF);
    
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mButton, alpha, scaleX, scaleY,color,rotation);
    animator.setInterpolator(new OvershootInterpolator());
    animator.setDuration(5000).start();
    

    相关文章

      网友评论

          本文标题:Android动画之 PropertyValuesHolder

          本文链接:https://www.haomeiwen.com/subject/fumtjxtx.html