我有一个引用三个视图的障碍。这三个视图在彼此之下,如下所示:
---- View A
---- View B
---- Group
--------- Barrier
---- View D
View D对 Barrier 有约束,View B 和 Group 在任何时候都可能成为View.GONE
。
此外,该组最初是空的。我以编程方式扩展视图 B 下的视图,并将所有视图与组相关联。
但问题是,当我将视图膨胀到组中时,视图 D不会移动并停留在视图 B 下方。
显示组、障碍和视图 D 的代码:
<androidx.constraintlayout.widget.Group
android:id="@+id/group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/view_b" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/header_barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="group, view_a, view_b" />
<View
android:id="@+id/bottom_shadow"
android:layout_width="0dp"
android:layout_height="@dimen/grid_8"
android:background="@drawable/orders_shadow_white"
app:layout_constraintBottom_toBottomOf="@id/barrier"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />