公告
财富商城
积分规则
提问
发文
2020-03-24 04:26发布
孤傲高冷的网名
How can I overlap items in RecyclerView? Like stacking cards.
Thanks in advance.
You have to write your own LayoutManager or extends LinearLayoutManager
To overlap recyclerView rows, you can use this.
Add this class to your activity. You can customize the vertOverlap.
public class OverlapDecoration extends RecyclerView.ItemDecoration { private final static int vertOverlap = -40; @Override public void getItemOffsets (Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { final int itemPosition = parent.getChildAdapterPosition(view); if (itemPosition == 0) { return; } outRect.set(0, vertOverlap, 0, 0); } } `
After that add your decoration to recyclerView before setting its layout manager, and we are done.
mRecyclerView.addItemDecoration(new OverlapDecoration()); mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
Thanks to the @MojoTosh https://stackoverflow.com/a/29067942/6255073
最多设置5个标签!
You have to write your own LayoutManager or extends LinearLayoutManager
To overlap recyclerView rows, you can use this.
Add this class to your activity. You can customize the vertOverlap.
After that add your decoration to recyclerView before setting its layout manager, and we are done.
Thanks to the @MojoTosh https://stackoverflow.com/a/29067942/6255073