This is my app where is the problem exists
I want my items to fit like this app
I'm using a RecyclerView
with GridLayoutManager
. My problem as you see in the image that the grid items aren't the same height when one of the items has a longer text. I'm loading the data from firebase and the notify the Adapter
when the list has the data. I tried everything but can't find a solution to auto fit the items like the second image attached. Any help, please?
Here is my recyclerview item layout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
>
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:cardCornerRadius="10dp"
android:layout_margin="5dp"
app:cardBackgroundColor="#fff"
app:cardElevation="5dp"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/cartoonImg"
android:layout_width="match_parent"
android:layout_height="120dp"
android:scaleType="fitXY"
app:imgUrl="@{cartoon.thumb}"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
tool:text="Cartoon Name"
android:gravity="center"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
android:textColor="@color/colorPrimary"
android:text="@{cartoon.title}" />
</LinearLayout>
</android.support.v7.widget.CardView>
</FrameLayout>