我有MotionLayout。还有几个场景,比如1、3、4,如何通过代码选择,比如工作中切换?
app:layoutDescription="@xml/game_start_xml_colo_scene2" <androidx.constraintlayout.motion.widget.MotionLayout
android:id="@+id/Colo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/chars_layout"
android:layout_below="@+id/topLayout"
android:layout_centerHorizontal="true"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:background="@drawable/main_game_board"
app:layoutDescription="@xml/game_start_xml_colo_scene2">发布于 2021-07-19 01:26:39
您可以在MotionLayout膨胀期间对其进行设置。这已经被用于基于景观/肖像可用计算等选择场景。
一旦MotionLayout启动(超过onAttachToWindow),就不支持更改MotionScene。(但这可能是可能的)。
在onAttachToWindow期间,MotionLayout构建了一个状态机,其中包含转换图和ConstraintSets、当前事务、进度、timeCycles的时钟等。如果MotionSceen足够简单,这可能是可能的。
但你不应该非得这么做。MotionScene可以包含任意数量的转换和ConstraintSets。ConstraintSets可以放在单独的文件中(在2.1中)。您可以在运行时以编程方式添加或更改过渡和ConstraintSets。
尽管如此,这是一个将在3.0中支持的功能。
https://stackoverflow.com/questions/68429442
复制相似问题