我应该为 RecyclerView 使用什么 LayoutManager 以避免均匀分布卡片?

What LayoutManager should I use for a RecyclerView to avoid distributing cards evenly?

tl;dr: 我需要做什么才能从第一张图片而不是第二张图片(关于蓝色方块)获得结果?


首先,代码片段位于 https://gist.github.com/exhuma/125ec8a5e32b395fd786 和一张供参考的图片,代表预期的结果:

我有一个包含 3 个 RecyclerView 的应用程序。中间有一个 "main" 列表,左右各有两个 "status views"。主列表按预期工作,并且应该是可滚动的。左边和右边的卡片很少(如果有的话)填满整个屏幕高度。滚动将是一个不错的选择,但不是必需的。它们都代表某种 "pending queue" 项目,这些项目很快就会出现在主列表中,并以小图标显示。

我尝试以与中央视图相同的方式处理业务。但是当我这样做时,它导致 "queue" 列表中的卡片像这样均匀分布:

我的问题是:LayoutManager 是做什么的? 或者我应该使用 RecyclerView 之外的其他东西吗?喜欢 ListView?

解决方案是强制 RecyclerView 的卡片为固定大小。替换为:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <ImageView
        android:id="@id/statusIcon"
        android:maxHeight="10dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

有了这个:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <ImageView
        android:id="@id/statusIcon"
        android:layout_width="20dp"
        android:layout_height="20dp" />
</LinearLayout>

显然,这不会随屏幕尺寸缩放。仍然可能有更好的解决方案。这暂时有效...