ActivityOptions.makeSceneTransitionAnimation似乎并不存在并不、存在、ActivityOptions、makeSceneTransitionAnimation

2023-09-06 13:25:41 作者:墨屿°

Android的大号推出了全新的动画功能:在不同的活动相似的看法之间的动画。它的记录这里。

我试图使用 ActivityOptions.makeSceneTransitionAnimation ,但它似乎并没有在SDK中可见(或罐子的话),所以我试图使用反射,并返回空值。

有没有其他人得到它的工作?

解决方案

好吧,我得到它的工作。

这似乎是设置在styles.xml的价值是完全忽略了。

您需要做的每一项活动的onCreate到那的固定式

  getWindow()requestFeature(Window.FEATURE_CONTENT_TRANSITIONS)。
过渡过渡= //负载变化在这里。
。getWindow()setSharedElementEnterTransition(过渡);
。getWindow()setSharedElementExitTransition(过渡);
 

按照同样的错误ViewAnimationUtils了,你会看到Android的Studio中的错误,它会编译并运行良好,但。

Activity动画演练

Android L introduced a new animations feature: animating between similar Views in different activities. It's documented here.

I've tried to use ActivityOptions.makeSceneTransitionAnimation, but it doesn't seem to be visible in the SDK (or in the jar at all), so I tried using reflection, and it returns a null value.

Has anyone else got it working?

解决方案

Okay, I got it working.

It seems like setting the value in styles.xml is completely ignored for now.

You'll need to do this in each Activity's onCreate till that's fixed

getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
Transition transition = // load transition here.
getWindow().setSharedElementEnterTransition(transition);
getWindow().setSharedElementExitTransition(transition);

As per the same bug ViewAnimationUtils has, you'll see errors in Android Studio, it'll compile and run fine though.