EverythingMe / overscroll-decor

Android: iOS-like over-scrolling effect applicable over almost all scrollable Android views.
BSD 2-Clause "Simplified" License
2.85k stars 400 forks source link

Custom layout managers #52

Open salvonos opened 7 years ago

salvonos commented 7 years ago

I am trying to use your library on my recycler view. I use a default GridLayoutManager however, I get the error

Recycler views with custom layout managers are not supported by this adapter out of the box

How can I solve this error?

OverScrollDecoratorHelper.setUpOverScroll(recyclerView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL);

    layoutManager = new GridLayoutManager(this, spanCount, GridLayoutManager.VERTICAL, false);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            //stagger rows custom
            //return (position == 0 ? 2 : 1);
            return (position % 3 == 0 ? 1 : 1);
        }
    });

    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(layoutManager);
salvonos commented 7 years ago

Solved it.

I have put

> OverScrollDecoratorHelper.setUpOverScroll(recyclerView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL);

At the end of the code

naive17 commented 6 years ago

Can you explain better?

ola-wale commented 6 years ago

doing this OverScrollDecoratorHelper.setUpOverScroll(recyclerView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL); before setting a layout manager on your recycler view will trigger this error.