Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eugenebrusov/b995b18ec25274270d398e8b473a387a to your computer and use it in GitHub Desktop.
Save eugenebrusov/b995b18ec25274270d398e8b473a387a to your computer and use it in GitHub Desktop.
CardView - media 1:1, primary text, subtext and actions
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/CardView.Light"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp">
<android.support.constraint.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/media_image"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_constraintDimensionRatio="H,1:1"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#7F000000"
app:layout_constraintTop_toTopOf="@+id/top_space"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<Space
android:id="@+id/top_space"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/primary_text"/>
<TextView
android:id="@+id/primary_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:textColor="#FFFFFFFF"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/sub_text"/>
<TextView
android:id="@+id/sub_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="#B3FFFFFF"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/action_button_1" />
<Button
style="@style/Widget.AppCompat.Button.Borderless"
android:id="@+id/action_button_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:minWidth="0dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:textColor="#FFFFFFFF"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<Button
style="@style/Widget.AppCompat.Button.Borderless"
android:id="@+id/action_button_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:minWidth="0dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:textColor="#FFFFFFFF"
app:layout_constraintTop_toTopOf="@+id/action_button_1"
app:layout_constraintStart_toEndOf="@+id/action_button_1" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment