Я использую ConstraintLayout в своем проекте Android, я помещаю четыре кнопки изображения в пользовательском интерфейсе, я надеюсь, что расстояние между 4 кнопками изображения равно расстоянию, кажется, что обе Layout A и Макет B может сделать это, вы можете увидеть результат Изображение AB .
Чем отличаются Макет A и МакетB ?
Макет A
<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:id="@+id/camera_ui_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/btnFlash"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginLeft="@dimen/margin_xsmall"
android:layout_marginBottom="@dimen/margin_medium"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/btnVideo"
app:srcCompat="@drawable/ic_flash_on" />
<ImageButton
android:id="@+id/btnVideo"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginBottom="@dimen/margin_medium"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/btnFlash"
app:layout_constraintRight_toLeftOf="@+id/btnPicture"
app:srcCompat="@drawable/ic_menu" />
<ImageButton
android:id="@+id/btnPicture"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginBottom="@dimen/margin_medium"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/btnVideo"
app:layout_constraintRight_toLeftOf="@+id/btnAction"
app:srcCompat="@drawable/ic_menu" />
<ImageButton
android:id="@+id/btnAction"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginRight="@dimen/margin_xsmall"
android:layout_marginBottom="@dimen/margin_medium"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toRightOf="@+id/btnPicture"
app:srcCompat="@drawable/ic_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
Макет B
<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:id="@+id/camera_ui_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/btnFlash"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginLeft="@dimen/margin_xsmall"
android:layout_marginBottom="@dimen/margin_medium"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintLeft_toLeftOf="parent"
app:srcCompat="@drawable/ic_flash_on" />
<ImageButton
android:id="@+id/btnVideo"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginBottom="@dimen/margin_medium"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/btnFlash"
app:layout_constraintRight_toLeftOf="@+id/btnPicture"
app:srcCompat="@drawable/ic_menu" />
<ImageButton
android:id="@+id/btnPicture"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginBottom="@dimen/margin_medium"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/btnVideo"
app:layout_constraintRight_toLeftOf="@+id/btnAction"
app:srcCompat="@drawable/ic_menu" />
<ImageButton
android:id="@+id/btnAction"
android:layout_width="@dimen/round_button_medium"
android:layout_height="@dimen/round_button_medium"
android:layout_marginRight="@dimen/margin_xsmall"
android:layout_marginBottom="@dimen/margin_medium"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="@drawable/ic_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
Изображение AB