MotionLayout中的ViewStub保持不可见

问题描述 投票:1回答:1

我有一个带有某些视图和ViewStub的现有ConstraintLayout。我将其转换为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。当我在不使用Motionscene的情况下使用ConstraintLayout或MotionLayout时,它可以工作,这意味着视图存根被其内容正确替换,并且所有可见。[当我使用运动场景时,按钮的动画可以正确播放,但ViewStub的膨胀后的布局是不可见的((因为我可以在布局检查器中看到它,所以没有消失)。)>

我尝试使用该属性

app:visibilityMode =“ ignore”

未成功

是因为MotionLayout仍在开发中还是错过了某些东西? (另一个wrap_content问题?)。

谢谢你!

我有一个带有某些视图和ViewStub的现有ConstraintLayout。我将其转换为MotionLayout,但不会显示ViewStub。我有以下布局:

android android-constraintlayout android-motionlayout
1个回答
0
投票

一些笔记。首先,为了使viewStub出现,必须对其进行充气,而不仅仅是可见性设置。因此,请确保您在代码中的某个位置调用了stub.inflate()

© www.soinside.com 2019 - 2024. All rights reserved.