0

I use recyclerView with LinearLayoutManager and I need to do something like this (one items over other)

http://take.ms/kU8Zv I think that this can be done by overriding a few methods in LayoutManager, but i don't know which of them. How i can to do that?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Hank Moody
  • 354
  • 2
  • 15

2 Answers2

1
@Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
            RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        if (mDivider == null) {
            return;
        }
        if (parent.getChildPosition(view) < 1) {
            return;
        }

        if (getOrientation(parent) == LinearLayoutManager.VERTICAL) {
            outRect.top = mDivider.getIntrinsicHeight();
        } else {
            outRect.left = mDivider.getIntrinsicWidth();
        }
    }
USKMobility
  • 5,721
  • 2
  • 27
  • 34
  • Thx, but ItemDecorator doesn't suit me, cause' next element is not created until you reach the end of the previous one, this can be seen a sharp appearance of items that have +1 position – Hank Moody Oct 04 '15 at 14:25
  • You can also define multiple layout in recyclerview , visit http://stackoverflow.com/questions/26245139/how-to-create-recyclerview-with-multiple-view-type – USKMobility Oct 04 '15 at 14:33
0

After some searching I found this solution, I hope it will help someone https://androiddevx.wordpress.com/2014/12/05/recycler-view-pre-cache-views/

Hank Moody
  • 354
  • 2
  • 15