Skip to content

Instantly share code, notes, and snippets.

@buildbro
Created July 1, 2019 00:54
Show Gist options
  • Save buildbro/a702e807211a6052e1a730a76550cdfa to your computer and use it in GitHub Desktop.
Save buildbro/a702e807211a6052e1a730a76550cdfa to your computer and use it in GitHub Desktop.
code sample for youtube tutorial on moving UI from LinearLayout to ConstraintLayout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:text="Name"
android:textColor="#000000" />
<TextView
android:id="@+id/code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/name"
app:layout_constraintStart_toStartOf="@id/name"
android:text="*---#"
android:textColor="#888888" />
<ImageView
android:id="@+id/delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:padding="8dp"
android:src="@drawable/ic_delete_grey600_24dp"
app:layout_constraintEnd_toStartOf="@+id/copy"
app:layout_constraintTop_toTopOf="@+id/share" />
<ImageView
android:id="@+id/copy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/share"
app:layout_constraintTop_toTopOf="@id/share"
android:padding="8dp"
android:src="@drawable/ic_content_copy_grey600_24dp" />
<ImageView
android:id="@+id/share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/code"
android:padding="8dp"
android:paddingRight="0dp"
android:src="@drawable/ic_share_variant_grey600_24dp" />
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
app:layout_constraintTop_toBottomOf="@id/share"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="0dp"
android:background="#CCCCCC" />
</androidx.constraintlayout.widget.ConstraintLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment