そのようなUIを完成させたい
<?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"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/target"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="20dp"
android:background="@android:color/holo_green_dark"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@android:color/holo_green_light"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="@id/target"
app:layout_constraintStart_toStartOf="@id/target"
app:layout_constraintTop_toBottomOf="@id/target"
app:layout_constraintBottom_toBottomOf="@id/target"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
効果
次の2つの文は理解しにくいです
app:layout_constraintTop_toBottomOf="@id/target"
app:layout_constraintBottom_toBottomOf="@id/target"
それでは削除しますね
削除する
つまり、上から下、下から上へ。彼らは縛られています。当然真ん中まで走ります。非常にスタイリッシュ