gpt4 book ai didi

android - ConstraintLayout Barrier 在设计 View 中不可见

转载 作者:太空宇宙 更新时间:2023-11-03 13:39:56 28 4
gpt4 key购买 nike

我试图在 Android Studio 中为我的 ConstraintLayout 添加一个屏障,但它在设计 View 中没有按应有的方式显示。

我一直在关注this tutorial ,但我无法让一切正常工作。

我目前正在使用:

  • 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>

在设计 View 中,它看起来像 this

屏障粘在布局的边缘,无论我做什么都不会移动。如果我设置 barrierDirection startleft 它根本不可见。如果我设置 endright 虚线会显示,但会卡在布局的左侧。

障碍 seem to work fine在另一个从头开始的项目中,但这使用了 android.support.constraint.ConstraintLayout 而不是 androidx 库。

最佳答案

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

关于android - ConstraintLayout Barrier 在设计 View 中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54605100/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com