Last active
October 11, 2017 14:16
-
-
Save eugenebrusov/1a43bc87199e215aa48b07d5c88b63a5 to your computer and use it in GitHub Desktop.
CardView - media 16:9, primary text, subtext, actions and expandable supporting text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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,16:9" | |
app:layout_constraintTop_toTopOf="parent" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintBottom_toTopOf="@+id/primary_text" | |
app:layout_constraintVertical_chainStyle="packed" /> | |
<TextView | |
android:id="@+id/primary_text" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="24dp" | |
android:layout_marginStart="16dp" | |
android:layout_marginEnd="16dp" | |
android:textAppearance="@style/TextAppearance.AppCompat.Headline" | |
android:textColor="#DE000000" | |
app:layout_constraintTop_toBottomOf="@+id/media_image" | |
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:textAppearance="@style/TextAppearance.AppCompat.Body1" | |
android:textColor="#8A000000" | |
app:layout_constraintTop_toBottomOf="@+id/primary_text" | |
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_marginTop="16dp" | |
android:layout_marginStart="8dp" | |
android:minWidth="0dp" | |
android:paddingStart="8dp" | |
android:paddingEnd="8dp" | |
android:textColor="#DE000000" | |
app:layout_constraintTop_toBottomOf="@+id/sub_text" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintBottom_toTopOf="@+id/supporting_text" /> | |
<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="#DE000000" | |
app:layout_constraintTop_toTopOf="@+id/action_button_1" | |
app:layout_constraintStart_toEndOf="@+id/action_button_1" /> | |
<ImageButton | |
android:id="@+id/expand_button" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginEnd="8dp" | |
android:layout_marginBottom="0dp" | |
android:background="#00FFFFFF" | |
android:padding="6dp" | |
app:srcCompat="@drawable/ic_expand_more_black_36dp" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintBottom_toBottomOf="@+id/action_button_1" /> | |
<TextView | |
android:id="@+id/supporting_text" | |
android:layout_width="0dp" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="16dp" | |
android:layout_marginStart="16dp" | |
android:layout_marginEnd="16dp" | |
android:layout_marginBottom="24dp" | |
android:lineSpacingExtra="8dp" | |
android:textAppearance="@style/TextAppearance.AppCompat.Body1" | |
android:textColor="#DE000000" | |
android:visibility="gone" <!-- To expand you set visibility to "visible". To collapse you set visibility to "gone" --> | |
app:layout_constraintTop_toBottomOf="@+id/action_button_1" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintBottom_toBottomOf="parent"/> | |
</android.support.constraint.ConstraintLayout> | |
</android.support.v7.widget.CardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<vector android:alpha="0.87" android:height="36dp" | |
android:viewportHeight="24.0" android:viewportWidth="24.0" | |
android:width="36dp" xmlns:android="http://schemas.android.com/apk/res/android"> | |
<path android:fillColor="#FF000000" android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"/> | |
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<vector android:alpha="0.87" android:height="36dp" | |
android:viewportHeight="24.0" android:viewportWidth="24.0" | |
android:width="36dp" xmlns:android="http://schemas.android.com/apk/res/android"> | |
<path android:fillColor="#FF000000" android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/> | |
</vector> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment