Good day.
How to make a live view of CardView in RecyclerView ?
The user can create a card with an image and without. The image in the template does not exceed 120dp .
If the user adds an image, there is no problem. If it does not add, it creates an empty space of 120dp , which, according to the idea, should not be, only text and description.
If you make the height of the image wrap_content , then the card may be full screen, which is unacceptable.
Template:
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ImageView android:id="@+id/item_image" android:layout_width="match_parent" android:layout_height="120dp" android:scaleType="centerCrop" android:src="@drawable/forest" /> <TextView android:id="@+id/item_title" android:layout_width="250dp" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_alignParentTop="true" android:layout_marginStart="30dp" android:text="TextView" /> <TextView android:id="@+id/item_description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="10dp" android:text="TextView" /> </LinearLayout> </android.support.v7.widget.CardView> 