【发布时间】:2019-06-21 08:16:19
【问题描述】:
This is my app where is the problem exists
I want my items to fit like this app
我正在使用RecyclerView 和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>
【问题讨论】:
-
嗨,欢迎来到 StackOverFlow。请提供
recyclerviewitem.xml的布局 -
你需要更改
height of the item wrap_content to 100sp or what ever you liked -
我添加了我的 recyclerview 项目布局 ankuranurag2
-
Vishal Yadav 我想要一种自动调整方式而不是固定尺寸。
标签: java android android-recyclerview gridlayoutmanager