英雄转变不工作的Android棒棒糖 [英] Hero Transitions not working Android Lollipop
问题描述
我试图使活动之间的动画/过渡,但我不能让它完美好。我找不到任何帮助指导。
你能告诉我如何创建一个ActivityOptions tranistion,就像这样:
<一href=\"http://3.bp.blogspot.com/-dadidlU3muU/VE6og4Ra_BI/AAAAAAAAA8E/uVCWrYMetGI/s400/herotransition.gif\" rel=\"nofollow\">http://3.bp.blogspot.com/-dadidlU3muU/VE6og4Ra_BI/AAAAAAAAA8E/uVCWrYMetGI/s400/herotransition.gif
I tried to make animations/transitions between activities but I couldn't make it perfect and good. And I couldn't find any helping guide. Can you tell me how to create an ActivityOptions tranistion, like this: http://3.bp.blogspot.com/-dadidlU3muU/VE6og4Ra_BI/AAAAAAAAA8E/uVCWrYMetGI/s400/herotransition.gif
一步一步?
谢谢你。
Step by step? Thanks.
推荐答案
您需要两个共享的元素:
You need two shared elements:
- 卡时(全部的卡)从列表视图将被共享和
映射到详细信息视图活动的根本看法。您可以
过渡与一个ChangeBounds。 - 从列表视图中的ImageView将被共享,并映射到详细视图活动ImageView的。您可以使用TransitionSet既ChangeBounds和ChangeImageTransform。
- The card (the entire card) from the list view will be shared and mapped to the root view of the detail view activity. You can transition that with a ChangeBounds.
- The ImageView from the list view will be shared and mapped to the ImageView in the detail view activity. You can use a TransitionSet with both ChangeBounds and ChangeImageTransform.
这意味着,您的活动的选项将是这个样子:
That means that your activity options will look something like this:
ActivityOptions.makeSceneTransition(YourActivity.this, Pair.create(yourCardViewInstance, "cardView"), Pair.create(yourImageViewInstance, "imageView")
最后,请确保您的第二个活动的意见都匹配在您ActivityOptions过渡名称。例如。
Finally, make sure that the views in your second activity have transition names that match those in your ActivityOptions. E.g.
<FrameLayout
android:transitionName="cardView">
<ImageView
android:transitionName="ImageView">
...
这篇关于英雄转变不工作的Android棒棒糖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!