Android 场景和过渡、动画之间的区别以及何时使用它们

标签 android animation android-studio transition scene

所以我最近一直在阅读开发者网站上的过渡和动画:

动画

http://developer.android.com/training/animation/index.html

场景和过渡

http://developer.android.com/training/transitions/index.html

我看不出它们之间有什么大的区别,并且认为它们相对相同。

我知道过渡更多的是在 View 之间切换,而动画更多的是为了增加惊喜因素,例如当你用手指按住它时弹出一个按钮,但我相信它还有更多的东西。

如果可能的话,我正在寻找有关两者之间差异以及何时应该使用它们的详细答案?

最佳答案

我遇到了 this article前几天试图找到在使用数据绑定(bind)时制作动画的最佳实践。作者解释了两种方法,分别使用动画(使用 BindingAdapter,参见方法 1)和过渡(使用 onRebindCallback,参见方法 2)。我认为他最后写的总结/比较也在高层次上回答了你的问题。我个人认为最重要的一点是动画提供了更细粒度的控制,同时过渡是可重用的(即使您的 View 略有变化)。

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)

关于Android 场景和过渡、动画之间的区别以及何时使用它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37011684/

相关文章:

c++ - android studio 中的外部 C++ 源文件?

android - Gradle 在 Android Studio 中找不到属性文件的属性

android - 无法在 Android Eclipse 的 FileExplorer 中查看 SDCard 文件夹

android - 使用 url 创建微调器时 R.java 出错

html - 使用关键帧将边框动画化为透明

Android 库模块与功能模块

java - 非 Activity Java 类中的 Dagger 2 注入(inject)

android - 数据更改时自动搜索 TextView 下拉列表闪烁

javascript - 从 <use> 标签对 SVG 路径进行动画处理

css - 变换:旋转不起作用 - 但适用于原始模型