Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
297 views
in Technique[技术] by (71.8m points)

android - How do I layout nested RecyclerViews, while remaining performant?

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

enter image description here

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 will also work with latest recyclerview

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...