Android 场景和过渡、动画之间的区别以及何时使用它们
Android Difference between Scenes and Transitions, Animations, and when to use them
所以我最近一直在阅读开发者网站上的过渡和动画:
动画
http://developer.android.com/training/animation/index.html
场景和过渡
http://developer.android.com/training/transitions/index.html
我看不出它们之间有什么大的区别,认为它们比较相似。
我知道过渡更多的是在视图之间切换,而动画更多的是为了增加惊喜因素,例如当你用手指按住它时弹出一个按钮,但我相信除了这些之外还有更多.
如果可能的话,我正在寻找有关两者之间差异以及何时应该使用它们的详细答案?
前几天我遇到了 this article 试图找到在使用数据绑定时制作动画的最佳实践。作者解释了两种方法,分别使用动画(使用 BindingAdapter,参见方法 1)和过渡(使用 onRebindCallback,参见方法 2)。我认为他最后写的 summary/comparison 也高层次地回答了你的问题。我个人认为最重要的一点是动画提供了更细粒度的控制,同时过渡是可重用的(即使您的视图略有变化)。
Advantages of the BindingAdapter mechanism:
- Fine-grained control — only the views you want to animate will animate
- Less overhead than transitions (performance)
- Very flexible — you can create whatever animation you want
Advantages of the OnRebindCallback mechanism:
- Simple to use
- Don’t have to use custom attributes (or override default behavior)
- Can animate many things with the same code (see Transition subclasses)
所以我最近一直在阅读开发者网站上的过渡和动画:
动画
http://developer.android.com/training/animation/index.html
场景和过渡
http://developer.android.com/training/transitions/index.html
我看不出它们之间有什么大的区别,认为它们比较相似。
我知道过渡更多的是在视图之间切换,而动画更多的是为了增加惊喜因素,例如当你用手指按住它时弹出一个按钮,但我相信除了这些之外还有更多.
如果可能的话,我正在寻找有关两者之间差异以及何时应该使用它们的详细答案?
前几天我遇到了 this article 试图找到在使用数据绑定时制作动画的最佳实践。作者解释了两种方法,分别使用动画(使用 BindingAdapter,参见方法 1)和过渡(使用 onRebindCallback,参见方法 2)。我认为他最后写的 summary/comparison 也高层次地回答了你的问题。我个人认为最重要的一点是动画提供了更细粒度的控制,同时过渡是可重用的(即使您的视图略有变化)。
Advantages of the BindingAdapter mechanism:
- Fine-grained control — only the views you want to animate will animate
- Less overhead than transitions (performance)
- Very flexible — you can create whatever animation you want
Advantages of the OnRebindCallback mechanism:
- Simple to use
- Don’t have to use custom attributes (or override default behavior)
- Can animate many things with the same code (see Transition subclasses)