【问题标题】:Android Transitions: Go to other scene without animation on orientation changeAndroid过渡:在方向改变时转到其他没有动画的场景
【发布时间】:2015-09-27 07:50:09
【问题描述】:
我的布局中有两个Scenes。
首先是活动视图膨胀的原始场景。
另一个是第一个使用TransitionManager.go(secondScene);过渡到的场景
现在,当设备旋转时,会再次播放整个过渡。我想防止这种情况,并想直接显示第二个场景。我的 savedInstanceState 中有所有数据,所以我知道活动已重新创建,但我不知道如何在没有动画的情况下直接显示第二个状态。
任何帮助将不胜感激。谢谢。
【问题讨论】:
标签:
android
android-animation
android-transitions
【解决方案1】:
你可以为 TransitionSet 设置 null
TransitionManager.go(secondScene, null);
或
sceneRoot.removeAllViews();
View scene = inflate(getContext(),R.layout.second_scene, null);
sceneRoot.addView(scene);
【解决方案2】:
Scene 类有一个 enter 方法,如果您想在没有任何动画的情况下移动到下一个场景,可以调用该方法:
val nextScene = Scene.getSceneForLayout(root, nextSceneLayout, activity)
nextScene.enter()