---
# System prepended metadata

title: 2020-04-10 | Kotlin | Layout Constraints
tags: [android, kotlin, gobelins]

---

# 2020-04-10 | Kotlin | Layout Constraints

###### tags: `kotlin` `android` `gobelins`

## Example
```kotlin
<?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">

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guide_left"
        app:layout_constraintGuide_begin="20dp"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

    <androidx.constraintlayout.widget.Guideline
        android:id="@+id/guide_right"
        app:layout_constraintGuide_end="20dp"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/imageView"
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:src="@drawable/logo"
        android:layout_marginTop="30dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        />

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/label_identifiants"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="20dp"
        android:textStyle="bold"
        android:textSize="16dp"
        app:layout_constraintStart_toStartOf="@id/guide_left"
        app:layout_constraintEnd_toEndOf="@id/guide_right"
        app:layout_constraintTop_toBottomOf="@id/imageView"
        android:text="@string/label_identifiants"

        />

    <androidx.appcompat.widget.AppCompatEditText
        android:id="@+id/prenom"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="10dp"
        android:hint="@string/hint_prenom"
        android:textColor="@color/colorPrimaryLight"
        app:layout_constraintTop_toBottomOf="@id/label_identifiants"
        app:layout_constraintStart_toStartOf="@id/guide_left"
        app:layout_constraintEnd_toEndOf="@id/guide_right"
        android:drawableRight="@drawable/ic_info_outline_black_24dp"
        />

    <androidx.appcompat.widget.AppCompatEditText
        android:id="@+id/nom"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="10dp"
        android:hint="@string/hint_nom"
        android:textColor="@color/colorPrimaryLight"
        app:layout_constraintTop_toBottomOf="@id/prenom"
        app:layout_constraintStart_toStartOf="@id/guide_left"
        app:layout_constraintEnd_toEndOf="@id/guide_right"
        android:drawableRight="@drawable/ic_info_outline_black_24dp"
        />

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/label_email"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="20dp"
        android:textStyle="bold"
        android:textSize="16dp"
        app:layout_constraintStart_toStartOf="@id/guide_left"
        app:layout_constraintEnd_toEndOf="@id/guide_right"
        app:layout_constraintTop_toBottomOf="@id/nom"
        android:text="@string/label_email"
        />

    <androidx.appcompat.widget.AppCompatEditText
        android:id="@+id/email"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="10dp"
        android:hint="@string/hint_email"
        android:textColor="@color/colorPrimaryLight"
        app:layout_constraintTop_toBottomOf="@id/label_email"
        app:layout_constraintStart_toStartOf="@id/guide_left"
        app:layout_constraintEnd_toEndOf="@id/guide_right"
        />

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/label_password"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="20dp"
        android:textStyle="bold"
        android:textSize="16dp"
        app:layout_constraintStart_toStartOf="@id/guide_left"
        app:layout_constraintEnd_toEndOf="@id/guide_right"
        app:layout_constraintTop_toBottomOf="@id/email"
        android:text="@string/label_password"
        />

    <androidx.appcompat.widget.AppCompatEditText
        android:id="@+id/password"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="10dp"
        android:hint="@string/hint_password"
        app:layout_constraintTop_toBottomOf="@id/label_password"
        app:layout_constraintStart_toStartOf="@id/guide_left"
        app:layout_constraintEnd_toEndOf="@id/guide_right"
        android:inputType="textPassword"
        android:textColor="@color/colorPrimaryLight"
        android:drawableRight="@drawable/ic_info_outline_black_24dp"
        />

    <androidx.appcompat.widget.AppCompatEditText
        android:id="@+id/password_check"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="10dp"
        android:hint="@string/hint_password_check"
        app:layout_constraintTop_toBottomOf="@id/password"
        app:layout_constraintStart_toStartOf="@id/guide_left"
        app:layout_constraintEnd_toEndOf="@id/guide_right"
        android:inputType="textPassword"
        android:textColor="@color/colorPrimaryLight"
        />


    <androidx.appcompat.widget.AppCompatButton
        android:id="@+id/button_validate"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginEnd="10dp"
        android:layout_marginTop="20dp"
        app:layout_constraintTop_toBottomOf="@id/password_check"
        android:text="@string/login_button"
        app:layout_constraintStart_toStartOf="@id/guide_left"
        app:layout_constraintEnd_toEndOf="@id/guide_right"
        android:background="@drawable/my_button"
        android:textColor="@color/colorWhite"
        android:textSize="17dp"
        style="?android:attr/borderlessButtonStyle"
        />

</androidx.constraintlayout.widget.ConstraintLayout>
```