Computer scienceMobileAndroidUser InterfaceGraphics

ConstraintLayout vs RelativeLayout

Guidelines

Report a typo

Does this layout correctly follow the guideline that each view must have at least one constraint for each axis (horizontal and vertical)?

<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="Hello, World!"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Click Me!"
        app:layout_constraintTop_toBottomOf="@+id/textView1"/>

</androidx.constraintlayout.widget.ConstraintLayout>
Select one option from the list

Create a free account to access the full topic