一:水平方向
水平方向需要设置步骤如下
app:layout_constraintHorizontal_weight="1"
- 分别设置view1与view2的左右依赖
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constrain_bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/bg_top_cornel"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/map_view"
app:layout_constraintVertical_weight="2">
<View
android:id="@+id/view1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#ff0000"
app:layout_constraintHorizontal_weight="2"