개발/안드로이드(Android-Kotlin)

ConstraintLayout same width

----___<<<<< 2019. 9. 24. 19:20

ConstConstraintLayout 을 같은 넓이로 쪼개는 법을 알아봅니다.

 

 

코드는 아래와 같습니다.

 

<?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">

    <Button
        android:id="@+id/button1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Button 1"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/button2"
        app:layout_constraintStart_toStartOf="parent" />

    <Button
        android:id="@+id/button2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Button 2"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/button3"
        app:layout_constraintStart_toEndOf="@+id/button1" />

    <Button
        android:id="@+id/button3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Button 3"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/button4"
        app:layout_constraintStart_toEndOf="@+id/button2" />

    <Button
        android:id="@+id/button4"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="button4"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/button3"
        />



</androidx.constraintlayout.widget.ConstraintLayout>

app:layout_constraintEnd_toStartOf=""
app:layout_constraintStart_toEndOf=""

 

이 부분을 유심히 봐주시면 될 듯 합니다.

'개발 > 안드로이드(Android-Kotlin)' 카테고리의 다른 글

Viewpager (이미지 슬라이드)  (0) 2019.09.25
안드로이드 xml 한방에 적용하기  (0) 2019.09.24
Android:name = ""  (0) 2019.08.28
Primary key Realm  (0) 2019.08.22
dialog  (0) 2019.08.22