Hank Moody
Hank Moody

Reputation: 354

Set items offset in recyclerView for ability to place one above other

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?

Upvotes: 0

Views: 1730

Answers (2)

Hank Moody
Hank Moody

Reputation: 354

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/

Upvotes: 0

Umesh Singh Kushwaha
Umesh Singh Kushwaha

Reputation: 5741

@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();
        }
    }

Upvotes: 1

Related Questions