tja*_*and 5 android android-studio android-constraintlayout androidx
我正在尝试ConstraintLayout在Android Studio中添加一个障碍,但并没有在设计视图中显示出应有的方式。
我一直在关注本教程,但是无法正常工作。
我目前正在使用:
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 start或left根本不可见。如果我设置了,end或者right虚线出现了,但被卡在了布局的左侧。
在另一个从头开始的项目中,屏障似乎工作正常,但这使用的android.support.constraint.ConstraintLayout是androidx库而不是库的。
| 归档时间: |
|
| 查看次数: |
699 次 |
| 最近记录: |