多个视图之间的元素动画/过渡,不在活动或片段之间

问题描述 投票:0回答:2

我是android动画/过渡的新手,我想制作一个动画,如下所示:

我应该如何实现?

enter image description here

android animation transition
2个回答
1
投票

您可以尝试Motion Editor

要进行更深入的研究,请尝试在YouTube上观看一些视频教程。


0
投票

您有多种选择:

您可以使用此库进行两种类型的转换

  1. 使用TransitionManager。在这种情况下,您应该创建两个TransitionManager.go()并在这两个场景之间切换。 所有必需的动画将由过渡管理器处理。有关更多信息,请阅读scene链接

示例:

this
  1. 使用 Scene aScene; Scene anotherScene; // Create the scene root for the scenes in this app sceneRoot = (ViewGroup) findViewById(R.id.scene_root); // Create the scenes aScene = Scene.getSceneForLayout(sceneRoot, R.layout.a_scene, this); anotherScene = Scene.getSceneForLayout(sceneRoot, R.layout.another_scene, this); //transition from root scene to another scene TransitionManager.go(anotherScene); 。在这种情况下,您可以在TransitionManager.beginDelayedTransition(rootView)上设置beginDelayTransition,并且所有直接子对象都将在布局属性更改时进行动画处理。有关更多信息,请阅读paren链接

示例:

this
  • 使用// Get the root view and create a transition rootView = (ViewGroup) findViewById(R.id.mainLayout); mFade = new Fade(Fade.IN); // Start recording changes to the view hierarchy TransitionManager.beginDelayedTransition(rootView, mFade); // change in one of rootView childs childView.setWidth(100); // When the system redraws the screen to show this update, // the framework will animate the addition as a fade in 。有关更多信息,请阅读链接。
  • 您也可以使用MotionLayout。您可以创建两个片段首先使用键盘输入价格,然后创建第二个输入“ for”,其余视图保留在父级中。然后在标题的点击价格的这两个片段之间切换MotionLayout,也需要淡入/淡出标题价格和基于当前片段的“取消”按钮。您会看到类似gif的内容。
© www.soinside.com 2019 - 2024. All rights reserved.