FEATURE_ACTIVITY_TRANSITIONS与FEATURE_CONTENT_TRANSITIONS [英] FEATURE_ACTIVITY_TRANSITIONS vs. FEATURE_CONTENT_TRANSITIONS

查看:155
本文介绍了FEATURE_ACTIVITY_TRANSITIONS与FEATURE_CONTENT_TRANSITIONS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在理解这两个 Window 的区别时遇到了一些麻烦a>标志,并且不确定100%何时需要使用每个标志以及为什么使用.

I am having some trouble understanding the difference between these two Window flags and am not 100% certain when each needs to be used and why.

Window.FEATURE_ACTIVITY_TRANSITIONS 的文档说:

The docs for Window.FEATURE_ACTIVITY_TRANSITIONS say:

使活动能够运行活动转换通过发送或接收使用创建的ActivityOptions捆绑包 makeSceneTransitionAnimation(活动,配对[]) makeSceneTransitionAnimation(活动,视图,字符串).

Window.FEATURE_CONTENT_TRANSITIONS 的文档说:

请求更改窗口内容的标志使用 TransitionManager 进行动画处理.

TransitionManager 是使用以下方法设置的 setTransitionManager(TransitionManager).如果未设置,则将使用默认的 TransitionManager .

The TransitionManager is set using setTransitionManager(TransitionManager). If none is set, a default TransitionManager will be used.

文档指出,以下 Window 方法要求 FEATURE_ACTIVITY_TRANSITIONS 标志将被启用,但是对于是否还需要启用 FEATURE_CONTENT_TRANSITIONS 则一无所知(请注意,根据

The documentation states that the following Window methods require the FEATURE_ACTIVITY_TRANSITIONS flag to be enabled, but say nothing about whether or not the FEATURE_CONTENT_TRANSITIONS needs to be enabled as well (note that according to the source code, FEATURE_ACTIVITY_TRANSITIONS is true and FEATURE_CONTENT_TRANSITIONS is false for material-themed applications by default):

  • get {Enter,Exit,Return,Reenter} Transition()
  • set {Enter,Exit,Return,Reenter} Transition()
  • getSharedElement {Enter,Exit,Return,Reenter} Transition()
  • setSharedElement {Enter,Exit,Return,Reenter} Transition()
  • getTransitionBackgroundFadeDuration()
  • setTransitionBackgroundFadeDuration()
  • get{Enter,Exit,Return,Reenter}Transition()
  • set{Enter,Exit,Return,Reenter}Transition()
  • getSharedElement{Enter,Exit,Return,Reenter}Transition()
  • setSharedElement{Enter,Exit,Return,Reenter}Transition()
  • getTransitionBackgroundFadeDuration()
  • setTransitionBackgroundFadeDuration()

换句话说,似乎基于此信息, FEATURE_ACTIVITY_TRANSITIONS 是应用程序需要启用才能使用Lollipop的新Activity Transition API的功能标志.但是,令我感到困惑的是,来自Android开发者网站的本文指出启用了<要实现自定义活动转换,必须输入code> FEATURE_CONTENT_TRANSITIONS .

In other words, it seems like based on this information FEATURE_ACTIVITY_TRANSITIONS is the feature flag that applications will need to enable in order to use Lollipop's new Activity Transition APIs. What confuses me, however, is that this article from the Android Developers site states that enabling the FEATURE_CONTENT_TRANSITIONS is required in order to implement custom activity transitions.

这是我的问题:

  1. 这两个标志之间有什么区别?在这种情况下,活动过渡"和内容过渡"有什么区别?
  2. 为什么默认情况下启用 FEATURE_ACTIVITY_TRANSITIONS 并禁用 FEATURE_CONTENT_TRANSITIONS ?何时真正需要启用 FEATURE_CONTENT_TRANSITIONS 标志?
  3. 禁用 FEATURE_ACTIVITY_TRANSITIONS 并启用 FEATURE_CONTENT_TRANSITIONS 有意义吗?还是 FEATURE_CONTENT_TRANSITIONS 要求同时启用 FEATURE_ACTIVITY_TRANSITIONS ?
  1. What is the difference between these two flags? What is the difference between an "activity transition" and a "content transition" in this context?
  2. Why is FEATURE_ACTIVITY_TRANSITIONS enabled and FEATURE_CONTENT_TRANSITIONS disabled by default? When is enabling the FEATURE_CONTENT_TRANSITIONS flag actually required?
  3. Would it ever make sense to sense to disable FEATURE_ACTIVITY_TRANSITIONS and enable FEATURE_CONTENT_TRANSITIONS? Or does FEATURE_CONTENT_TRANSITIONS require FEATURE_ACTIVITY_TRANSITIONS to be enabled as well?

谢谢!

推荐答案

由于文档尚不明确,我很高兴有机会回答这些问题.

I'm glad I have an opportunity to answer these questions as the documentation is less than clear.

早期,有一个标志 FEATURE_CONTENT_TRANSITIONS 处理了两个功能.当Material应用程序启用后发生意外行为时,我们将它们拆分.因此,一些较早的文档可能仍然说您必须启用 FEATURE_CONTENT_TRANSITIONS 来获取活动转换,因为它们意味着 FEATURE_ACTIVITY_TRANSITIONS .

Early-on, there was one flag FEATURE_CONTENT_TRANSITIONS that handled both of the features. We split them when Material applications got unexpected behavior when it was enabled. So some older documentation may still say that you have to enable FEATURE_CONTENT_TRANSITIONS to get activity transitions when they mean FEATURE_ACTIVITY_TRANSITIONS.

  1. 这两个标志之间有什么区别?是什么活动过渡"与内容"之间的区别过渡"?

在此情况下的活动转换意味着您使用从 ActivityOptions.makeSceneTransitionAnimation 创建的捆绑软件调用 startActivity ,或者您的活动是从该捆绑软件开始的.活动过渡会修改您的布局(例如,元素的淡入,共享元素的移动),因此,如果您的活动不喜欢这样做,则应禁用 FEATURE_ACTIVITY_TRANSITIONS .

An activity transition in this context means that you call startActivity with a bundle created from ActivityOptions.makeSceneTransitionAnimation or, your activity was started with that bundle. Activity Transitions modify your layout (e.g. fading in elements, moving shared elements), so if your activity doesn't like that, you should disable FEATURE_ACTIVITY_TRANSITIONS.

当您调用 setContentView 时(第一次除外),内容转换将使用 TransitionManager .通常,您会遇到淡入淡出的感觉,但是如果您的活动"内容具有共同点,例如共享ID或使用 transitionName ,则会在两次操作之间获得 ChangeBounds 行为这些意见.您可以通过使用XML或代码来自定义与Window关联的 TransitionManager 来更改转换的详细信息.

Content transitions use a TransitionManager when you call setContentView (other than the first time). Typically, you'll get a cross-fade, but if your Activity's content has things in common, such as sharing IDs or using transitionName, you'll get ChangeBounds behavior between those Views. You can change the details of your transitions by customizing the TransitionManager associated with your Window either using XML or code.

  1. 为什么 FEATURE_ACTIVITY_TRANSITIONS 是默认启用还是 FEATURE_CONTENT_TRANSITIONS 禁用?什么时候是否启用实际上需要的 FEATURE_CONTENT_TRANSITIONS 标志?
  1. Why is FEATURE_ACTIVITY_TRANSITIONS enabled and FEATURE_CONTENT_TRANSITIONS disabled by default? When is enabling the FEATURE_CONTENT_TRANSITIONS flag actually required?

当您的内容更改时,

FEATURE_CONTENT_TRANSITIONS 使用TransitionManager.默认情况下,这是交叉淡入淡出的,对某些应用程序来说非常糟糕.另一方面,默认情况下, FEATURE_ACTIVITY_TRANSITIONS 对大多数应用程序不执行任何操作.您必须选择以这种方式开始活动,因此可以安全地打开它.

FEATURE_CONTENT_TRANSITIONS uses a TransitionManager when your content changes. By default, this is a cross-fade and that was very bad for some applications. On the other hand, FEATURE_ACTIVITY_TRANSITIONS doesn't do anything to most applications by default. You have to opt into starting an activity that way, so it is safe to turn on.

  1. 禁用有意义吗? FEATURE_ACTIVITY_TRANSITIONS 并启用 FEATURE_CONTENT_TRANSITIONS ?还是 FEATURE_CONTENT_TRANSITIONS 要求 FEATURE_ACTIVITY_TRANSITIONS 也要启用?
  1. Would it ever make sense to sense to disable FEATURE_ACTIVITY_TRANSITIONS and enable FEATURE_CONTENT_TRANSITIONS? Or does FEATURE_CONTENT_TRANSITIONS require FEATURE_ACTIVITY_TRANSITIONS to be enabled as well?

是的,但是不太可能.如果您的应用程序喜欢 FEATURE_CONTENT_TRANSITIONS ,则它应该可以很好地与 FEATURE_ACTIVITY_TRANSITIONS 一起使用.如果您想明确限制人们使用共享元素来调用您的活动,或者您不喜欢标准的Enter过渡效果,则可以将其禁用,以防止其他应用程序调用您的活动时产生效果.

Yes, but it is unlikely. If your application likes FEATURE_CONTENT_TRANSITIONS, it should work well with FEATURE_ACTIVITY_TRANSITIONS. If you want to explicitly limit people from calling your activity with shared elements or you don't like the standard enter transition effect, you can disable it to prevent the effect when another applications calls into yours.

这篇关于FEATURE_ACTIVITY_TRANSITIONS与FEATURE_CONTENT_TRANSITIONS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆