您可以使用以下代码将视图b位于视图a下方60dp:

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/a"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="View A"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

    <TextView
        android:id="@+id/b"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="View B"
        app:layout_constraintTop_toBottomOf="@+id/a"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@+id/a"
        app:layout_constraintVertical_bias="0"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintVertical_chainStyle="packed"
        android:layout_marginTop="60dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

在视图b的约束中,我们使用了app:layout_constraintTop_toBottomOf="@+id/a"来将视图b放置在视图a的下方,并使用android:layout_marginTop="60dp"将视图b向下移动60dp

android 我需要调整ConstraintLayout下面的 b 视图位于 a视图下方60dp

原文地址: http://www.cveoy.top/t/topic/dnTG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录