Цепочки элементов в ConstraintLayout
16.01.2025
Горизонтальная цепочка элементов
Пример горизонтальной цепочки
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="First"
app:layout_constraintRight_toLeftOf="@id/textView2"
app:layout_constraintLeft_toLeftOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Second"
app:layout_constraintLeft_toRightOf="@id/textView1"
app:layout_constraintRight_toLeftOf="@id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Third"
app:layout_constraintLeft_toRightOf="@id/textView2"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Распределение цепочки
Пример spread_inside:
spread_inside:
Пример packed:
packed:
Вес элементов

Вертикальная цепочка элементов
Пример вертикальной цепочки

Распределение цепочки
Вес элементов

PreviousРазмеры элементов в ConstraintLayoutNextПрограммное создание ConstraintLayout и позиционирование
Last updated