zoukankan      html  css  js  c++  java
  • 属性动画中同一个动画改变多个属性

    很多时候,你在同一个动画中会需要改变多个属性,例如在改变透明度的同时改变尺寸。

    如果使用 ViewPropertyAnimator,你可以直接用连写的方式来在一个动画中同时改变多个属性:

    view.animate()  
            .scaleX(1)
            .scaleY(1)
            .alpha(1);

    而对于 ObjectAnimator,是不能这么用的。不过你可以使用 PropertyValuesHolder 来同时在一个动画中改变多个属性。

    PropertyValuesHolder holder1 = PropertyValuesHolder.ofFloat("scaleX", 1);  
    PropertyValuesHolder holder2 = PropertyValuesHolder.ofFloat("scaleY", 1);  
    PropertyValuesHolder holder3 = PropertyValuesHolder.ofFloat("alpha", 1);
    
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(view, holder1, holder2, holder3)  
    animator.start();
  • 相关阅读:
    Chain of Responsibility Pattern
    Visitor Pattern
    Command Pattern
    Mediator Pattern
    Memento Pattern
    Observer Pattern
    State Pattern
    Strategy Pattern
    HTMLTestRunner修改Python3的版本
    loadrunner 检查点
  • 原文地址:https://www.cnblogs.com/krislight1105/p/10032823.html
Copyright © 2011-2022 走看看