Skip to content

Header Tutorial

Turing Technologies (Wynne Plaga) edited this page Mar 24, 2017 · 4 revisions

This tutorial is designed for a situation in which you want to have headers of one size and elements of another. Because the vanilla scroll logic is counting on every element being the same size, it won't work properly in this situation without a bit of extra work on your part. Luckily, we've developed a special class to help you out. Just follow this tutorial for some easy help.

Step 1

Implement IHeaderAdapter and ICustomScroller in your adapter class and include the required methods.

Step 2

Fill out the method according to this guide.

FastScrollerUtil.HeaderScrollManager manager;

@Override
public boolean isHeader(int index) {
    return //Is the view at 'index' a header//;
}

@Override
public void initScrollManager(int span) {
    manager = new FastScrollerUtil.HeaderScrollManager(span);
    manager.calcData(this);
}

@Override
public int getHeaderHeight() {
    return //Height of a header view//;
}

@Override
public int getRowHeight() {
    return //Height of a row//;
}

@Override
public int getDepthForItem(int index)
{
    return manager.getDepthForItem(index);
}

@Override
public int getTotalDepth()
{
    return manager.getTotalDepth();
}

@Override
public int getItemIndexForScroll(float scrollBarPos)
{
    return manager.getItemIndexForScroll(scrollBarPos);
}

Step 3

In the activity or fragment for the scroll bar add the following:

FastScrollerUtil.initHeaderScroller(//RecycelrView//);

Clone this wiki locally