AndroidX中的MotionLayout

时间:2019-02-05 15:17:12

标签: android androidx android-motionlayout

我想使用MotionLayout,但是我的应用程序在AndroidX中,我尝试使用常规的XML标签,但它们不起作用。布局编辑器仅显示带有标签名称的灰色框。如何在AndroidX中使用MotionLayout,或者如果无法使用,可以给我替代方法。

谢谢:)

现在它也发生在GridLayout上。这是屏幕截图:

enter image description here enter image description here

这很奇怪。 GridLayout的代码:

<androidx.gridlayout.widget.GridLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content>

</androidx.gridlayout.widget.GridLayout>

2 个答案:

答案 0 :(得分:0)

没有代码很难说, 但请确保您的xml标记正确: <androidx.constraintlayout.motion.widget.MotionLayout ...>

答案 1 :(得分:0)

MotionLayout已添加到ConstraintLayout 2.0中,因此请确保您拥有

implementation 'androidx.constraintlayout:constraintlayout:$androidConstraintLayoutVersion'

在应用的build.gradle中,其中$androidConstraintLayoutVersion至少为2.0