我有一个现有的 ConstraintLayout,其中包含一些视图和一个 ViewStub。我将它转换为 MotionLayout 但 ViewStub 不会出现。
我有以下布局:
<MotionLayout app:layoutDescription="@xml/motion_scene">
<Button id="button01"/>
<ViewStub id="stub" inflatedId="merger"/>
</MotionLayout>
对于给定的运动场景:
<MotionScene>
<Transition
app:constraintSetStart="@id/start"
app:constraintSetEnd="@id/end">
<OnClick app:clickAction="toggle" app:targetId="button"/>
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint android:id="@id/button" ...>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint android:id="@id/button" ...>
</ConstraintSet>
</MotionScene>
在我的活动中,我将 ViewStub 的可见性设置为 View.VISIBLE。当我使用没有动态场景的 ConstraintLayout 或 MotionLayout 时,它可以工作,这意味着视图存根被其内容正确替换并且所有内容都是可见的。 当我使用运动场景时,按钮的动画可以正确播放,但 ViewStub 的膨胀布局是不可见的(我猜没有消失,因为我可以在布局检查器中看到它)。
我尝试使用该属性
应用程序:visibilityMode="忽略"
没有成功
是因为 MotionLayout 仍在开发中还是我错过了什么?(另一个 wrap_content 问题?)。
先感谢您 !