ConcatAdapter 中的多个 LayoutManager [英] Multiple LayoutManager in ConcatAdapter

本文介绍了ConcatAdapter 中的多个 LayoutManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个像这张图片一样的 ConcatAdapter:

I want to implement an ConcatAdapter like this image:

此页面的 recyclerView 包含以下元素:

This page's recyclerView contains these elements:

  • 标题
  • 水平recyclerView(带分页)
  • 标题
  • 垂直 recyclerView(无分页)
  • 标题
  • 水平recyclerView(带分页)

但问题是我只能将一个 LayoutManager 设置为我所知道的包含 ConcatAdapter 的 recyclerView.

But the problem is I can set only one LayoutManager to recyclerView that holds ConcatAdapter as I know.

如何为每个适配器设置不同的布局管理器?或者使用 CocantAdapter 实现此页面的任何其他解决方案?

How can set different layoutmanager to each adapter? Or any other solution to implement this page with CocantAdapter?

(为什么是 ConcatAdapter?因为它解决了 NestedRecyclerView 的性能问题,即使我知道使用 recyclerViewPool)

(Why ConcatAdapter? Because it sovle performance prblems of nestedRecyclerView even with recyclerViewPool as I know)

推荐答案

不幸的是,这是不可能的.RecyclerView 适配器只是一个为每一行提供和绑定视图的组件.ConcatAdapter 也不例外,它只是从各个适配器重定向.

This unfortunately is not possible. A RecyclerView adapter is just a component to provide and bind views for each row. A ConcatAdapter is no different, it just redirects from the individual adapters.

如果它确实对布局管理器有任何控制,那么它真的会破坏 RecyclerView 模块化的全部意义,而这正是使它如此强大的原因.

If it did have any control over the layout managers it would really defeat the entire point of the modularity of RecyclerView, which is what makes it so powerful in the first place.

可以看一下源码这里 了解更多关于它是如何实现的.

You can take a look at the source code here to find out more about how it is implemented.

这篇关于ConcatAdapter 中的多个 LayoutManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆