我正在使用RecyclerViewwith GridLayoutManager。我的问题正如您在图像中看到的,当其中一个项目的文本较长时,网格项目的高度不同。我正在从 firebase 加载数据,并在Adapter列表有数据时通知。我尝试了一切,但找不到像附加的第二张图片一样自动调整项目的解决方案。请问有什么帮助吗?
这是我的 recyclerview 项目布局
<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>
白板的微信
RISEBY
慕标琳琳
相关分类