如何在recyclerview中显示这种类型的视图?

How to display this type of view in recyclerview?

我使用 GridLayoutManagerRecyclerView 但我需要每四行这个(提供图像)ViewType 给我解决方案

This type view

RecyclerView支持多个viewtypes.

看看这个:

How to create RecyclerView with multiple view type?

@Override
    public int getItemViewType(int position) {
        //Every 5th view should be different
        return position % 5;
    }

@Override
    public int getItemCount() {
        return 2;
    }

假设所有项目都有相似的观点试试这个:

    GridLayoutManager layoutManager = new GridLayoutManager(DashboardActivity.this, 2);

 layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {

                if (positions you wish to have a different view) {
                    return 2;
                }
                return 1;

            }
        });