androidx.constraintlayout.widget.constraintlayout没有可拖动的链

时间:2018-07-03 04:53:39

标签: android android-constraintlayout constraint-layout-chains androidx

我在布局中使用了 androidx.constraintlayout.widget.ConstraintLayout ,它没有显示链,也无法拖动任何小部件。我只输入要使用的约束。

<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="112dp"/>

这是androidx约束布局的屏幕截图示例: androidx.constraintlayout.widget.ConstraintLayout

但是当我尝试切换回 android.support.constraint.ConstraintLayout 时,我可以看到它

<android.support.constraint.ConstraintLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="112dp"/>

这是支持约束布局的示例屏幕截图: android.support.constraint.ConstraintLayout

这是错误还是什么?

编辑:

我当前的解决方案是从以下位置切换:

implementation 'androidx.constraintlayout:constraintlayout:1.1.2'

implementation 'com.android.support.constraint:constraint-layout:1.1.2'

但这不能解决我的问题,因为我不想使用支持。

2 个答案:

答案 0 :(得分:8)

我遇到了同样的问题,直到我意识到我应该使用Canary版本来解决它。 在稳定版本旁边安装Canary版本之后,打开项目,现在您可以使用此实现:

implementation 'androidx.constraintlayout:constraintlayout:1.1.2'

代替

implementation 'com.android.support.constraint:constraint-layout:1.1.2'

请记住,您可能需要执行以下操作:

  • 清洁项目
  • 重建
  • 使缓存无效/重启

我的问题用这种方法解决了。

答案 1 :(得分:3)

如果您使用的是最新的Android更新3.3.3,则从支持约束布局迁移到Android x:

datetime

要获取此信息,请更改gradle:

<android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

com.android.support.constraint:constraint-layout:1.1.3