Skip to content

Instantly share code, notes, and snippets.

@UdiOshi85
Created June 30, 2020 21:49
Show Gist options
  • Save UdiOshi85/4f44c5f2953f07b72c7995f5a17a204f to your computer and use it in GitHub Desktop.
Save UdiOshi85/4f44c5f2953f07b72c7995f5a17a204f to your computer and use it in GitHub Desktop.
Common layout to use in lists, image, name, description & checkbbox
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dimen_4_dp"
android:paddingBottom="@dimen/dimen_4_dp">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/dimen_16_dp"
android:paddingEnd="@dimen/dimen_16_dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_user_36dp" />
<TextView
android:id="@+id/name"
android:layout_width="@dimen/dimen_0_dp"
android:layout_height="wrap_content"
android:paddingStart="@dimen/dimen_12_dp"
android:paddingEnd="@dimen/dimen_12_dp"
android:textSize="@dimen/dimen_16_sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/subtitle"
app:layout_constraintEnd_toStartOf="@+id/checkbox"
app:layout_constraintStart_toEndOf="@+id/image"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:text="A name placeholder" />
<TextView
android:id="@+id/subtitle"
android:layout_width="@dimen/dimen_0_dp"
android:layout_height="wrap_content"
android:paddingStart="@dimen/dimen_12_dp"
android:paddingEnd="@dimen/dimen_12_dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/checkbox"
app:layout_constraintStart_toEndOf="@+id/image"
app:layout_constraintTop_toBottomOf="@+id/name"
tools:text="Some very long Lorem ipsum text" />
<CheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:checked="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment