ConstraintLayout屏障在设计视图中不可见

tja*_*and 5 android android-studio android-constraintlayout androidx

我正在尝试ConstraintLayout在Android Studio中添加一个障碍,但并没有在设计视图中显示出应有的方式。

我一直在关注本教程,但是无法正常工作。

我目前正在使用:

  • Android Studio 3.1.1
  • androidx.constraintlayout:constraintlayout:1.1.3

我尝试过的事情:

  • 使缓存无效/重启
  • 删除属性 tools:layout_editor_absoluteX
  • 摆弄!

这是我的test.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                                   xmlns:app="http://schemas.android.com/apk/res-auto"
                                                   xmlns:tools="http://schemas.android.com/tools"
                                                   android:layout_width="match_parent"
                                                   android:layout_height="match_parent">

    <Button
            android:text="Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/button" android:layout_marginTop="8dp"
            app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
            android:layout_marginStart="8dp"/>
    <Button
            android:text="Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/button2" android:layout_marginTop="8dp"
            app:layout_constraintTop_toBottomOf="@+id/button" app:layout_constraintStart_toStartOf="parent"
            android:layout_marginStart="8dp"/>
    <androidx.constraintlayout.widget.Barrier android:layout_width="wrap_content" android:layout_height="wrap_content"
                                              android:id="@+id/barrier2" app:barrierDirection="end"
                                              app:constraint_referenced_ids="button,button2"
                                              tools:layout_editor_absoluteX="411dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

在设计视图中,它看起来像这样

障碍固定在布局的边缘,无论我做什么都不会移动。如果设置barrierDirection startleft根本不可见。如果我设置了,end或者right虚线出现了,但被卡在了布局的左侧。

在另一个从头开始的项目中,屏障似乎工作正常,但这使用的android.support.constraint.ConstraintLayoutandroidx库而不是库的。

tja*_*and 5

升级到版本2.0.0-alpha3为我解决了这个问题。