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

查看:140
本文介绍了如何在保持性能的同时布局嵌套的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

整个布局(减去工具栏)是否可以是一个包含两个RecyclerViews的单个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也将与 最新 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天全站免登陆