?例如水平向右的两控件,左边的控件要覆盖一部分到右边控件。
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/two_situation_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:visibility="visible">
<ImageView
android:id="@+id/iv_two_situation_left"
android:layout_width="0dp"
android:layout_height="20dp"
android:src="@drawable/common_hui_m"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/place_holder"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginLeft="12dp"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<View
android:id="@+id/place_holder"
app:layout_constraintLeft_toLeftOf="@id/iv_two_situation_right"
app:layout_constraintTop_toTopOf="@id/iv_two_situation_right"
app:layout_constraintBottom_toBottomOf="@+id/tv_two_situation_right"
android:layout_marginLeft="7dp"
android:layout_width="0dp"
android:layout_height="0dp"/>
<ImageView
android:id="@+id/iv_two_situation_right"
android:layout_width="0dp"
android:layout_height="20dp"
android:src="@drawable/common_green_b"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginRight="12dp"
app:layout_constraintWidth_percent="0.1"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
</androidx.constraintlayout.widget.ConstraintLayout>
关键是PlaceHolderView设置边距大小与边距对齐方式
<View
android:id="@+id/place_holder"
app:layout_constraintLeft_toLeftOf="@id/iv_two_situation_right"
app:layout_constraintTop_toTopOf="@id/iv_two_situation_right"
app:layout_constraintBottom_toBottomOf="@+id/tv_two_situation_right"
android:layout_marginLeft="7dp"
android:layout_width="0dp"
android:layout_height="0dp"/>
|