【问题标题】:Displaying Multiple Image of different size in recycler view在回收站视图中显示不同大小的多个图像
【发布时间】:2020-08-13 00:53:54
【问题描述】:

我设置了一个典型的回收器适配器。适配器中的某些项目有图像,有时只有一个图像,最多 12 个。我想显示图像,如下图所示,具体取决于每个项目中的图像数量: 目前,我使用不同的布局文件来显示一组不同的图像。但问题是图像大小不一,我只为 4 个图像定义了集合,我使用 GLIDE 库来显示图像。

如果图像为 4 的代码,它们将调整为更大的图像尺寸

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="3"
    android:minHeight="@dimen/dp_200"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/image4"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:adjustViewBounds="true"
        android:contentDescription="@string/content_desc"
        android:scaleType="fitXY" />

    <ImageView
        android:id="@+id/image5"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:adjustViewBounds="true"
        android:contentDescription="@string/content_desc"
        android:scaleType="fitXY" />

    <ImageView
        android:id="@+id/image6"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:adjustViewBounds="true"
        android:contentDescription="@string/content_desc"
        android:scaleType="fitXY" />

</LinearLayout>

我正在寻找可以与 Target API 29 一起使用的任何可用库。以前的解决方案不适用于较新的 Target API。

【问题讨论】:

    标签: android android-layout android-recyclerview android-imageview


    【解决方案1】:

    我认为你可以使用 flexboxlayoutmanager,你可以查看你的示例here

    【讨论】:

      【解决方案2】:

      在垂直 Recycler View 中使用水平 Recycler View。通过此宽度,您的图像也会相应变化。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多