如何布局嵌套的 RecyclerViews,同时保持性能? [英] How do I layout nested RecyclerViews, while remaining performant?

查看:10
本文介绍了如何布局嵌套的 RecyclerViews,同时保持性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现类似于 Google Play 音乐的立即收听"布局.我在网上找到的每个例子都是一个简单的 RecyclerView.我正在努力实现更复杂的东西.类似的东西

I am trying to achieve something similar to Google Play Music's "Listen Now" layout. Every example I have found on the web is a single, simple RecyclerView. I am trying to achieve something much more complex. Something like

整个布局(减去工具栏)是否可以是一个单独的 RecyclerView,包含另外两个 RecyclerView?类似的东西

Can the whole layout (minus the toolbar) be a single RecyclerView, that contains two more RecyclerViews? Something like

最终,我想要实现的是如下布局,并保持性能.

Ultimately, what I want to achieve is a layout like the below, and stay performant.

<RecyclerView> //vertical
    <RecyclerView/> //vertical
    <RecyclerView/> //horizontal
    <LinearLayout/> //horizontal
</RecyclerView>

推荐答案

你不能在 recyclerview 标签中使用 recyclerview.而是在您的第一个适配器的 bindViewHolder 中再次调用 recyclerview 适配器,例如:-

You can't take recyclerview inside recyclerview tag. Rather in your first adapter's bindViewHolder call again recyclerview adapter like:-

InnerRecyclerviewAdapter adapter=new InnerRecyclerviewAdapter(context,urlistArray);
holder.recyclerView.setAdapter(adapter);
holder.recyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(layoutManager);

wrap_content 也适用于 latest recyclerview

wrap_content will also work with latest recyclerview

有关更多信息,请查看此链接 https://guides.codepath.com/android/Heterogenous-Layouts-inside-RecyclerView

for more info check out this link https://guides.codepath.com/android/Heterogenous-Layouts-inside-RecyclerView

这篇关于如何布局嵌套的 RecyclerViews,同时保持性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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