What I want to achieve:
What I did:
I have a button with 1 to 5 columns, when the user clic on the number of column he wants, the layout change but all the card are glued to each other. So far this is what I have been able to do: https://i.stack.imgur.com/OCzgW.jpg
My item:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/video_preview"
android:layout_width="match_parent"
android:layout_height="194dp"
android:scaleType="centerCrop"
tools:src="@drawable/img_error_v1"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/video_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceHeadline6"
android:maxLines="1"
tools:text="This is a really really really really really really really really really really really long title"
/>
<TextView
android:id="@+id/video_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:maxLines="1"
android:textAppearance="?attr/textAppearanceBody2"
android:textColor="?android:attr/textColorSecondary"
tools:text="This is the URL for now"
/>
</LinearLayout>
</LinearLayout>
My question:
How can I achieve this kind of change ? I have read about ItemDecoration
but I don't think I can change the layout_height
of my item. Do I need create one layout for each column screen ?