Copyright notice: This article is the blogger’s original article, shall not be reproduced without the permission of the blogger.

Android RecyclerView imitation Taobao order page realization, RecyclerView nesting RecyclerView sliding card not above, is a waste of feelings

Question: Recently, I encountered a problem in the project, similar to taobao order page. Because each order item may contain multiple specific items, in order to achieve this effect, generally, it is necessary to nest RecyclerView in RecyclerView, which will lead to that if there are too many specific items in the order item, more than one screen. Display effect will be stuck phenomenon, the reason is because of the existence of two RecyclerView, so that the release of the sliding view out of the current screen conflicts

Thinking: reference blog.csdn.net/Ideaqjjl/ar… Ideaqjjl analysis is very detailed, I get ideas from his analysis, for Copy party, the biggest pain is no source code, so integrate Ideaqjjl code, get the solution, each line as an Item, Equivalent to a RecyclerView to solve the result of nesting, the effect is really good, in this grey often thanks to Ideaqjjl to provide ideas and code

Solution: According to the RecyclerView grouping Settings, each row as an Item, equivalent to adding Item in a RecyclerView, so you can solve the problem well

@Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { MyViewHolder holder = new MyViewHolder(list.get(viewType).getView(mContext, parent, mIflater)); return holder; } /** * Each position is set as a separate item * viewType is set to position * @param position * @return */ @override public int getItemViewType(int position) { return position; }Copy the code

Conclusion with git address, if you have any questions, you can comment directly, welcome to criticize, common progress! Git.oschina.net/feiyangwei/…