Closed Marcelhozeman closed 8 years ago
Have your adapter extend ICustomScrolling and invoke the useCustomScolling() method on your bar setup.
Thanks! I forgot to set useCustomScrolling. Didn't see that method in the header tutorial. I've implemented this 2 interfaces now: FastScrollerUtil.IHeaderAdapter, ICustomScroller. And i am returning the height of my biggest ViewHolder in the getRowHeight method (IHeaderAdapter interface method). Is this the correct way to do this?
This won't work correctly. The logic behind the HeaderAdapter is 1 header and 1 item, whereas every header has the same height and every item has the same height...
Exactly. You'll need to remove that interface (keep ICustomScrolling) and fill in the methods yourself.
Thanks guys,
It works now.
Just wanted to say thanks very much for this great library! The only library I could find where I could have different row heights with scrolling working as expected.
@MinaHany @Marcelhozeman Hey, can you show some adapter code as far as implementing the IHeaderAdapter and ICustomScroller? We followed the Header tutorial to the tee but have issues with scrolling. It only seems to get one letter and doesn't work anywhere near expected. We're sure we did something wrong but have spent hours and are unable to figure it out. Appreciate it!
If you could provide a sample of your code that would be the easiest. If not I can write up an example tomorrow.
@joaquincorrales I am not implementing IHeaderAdapter, just ICustomScroller so not sure if my example will help but here it is anyway:
private List<Integer> sectionHeights;
@Override
public int getDepthForItem(int index) {
return getDepth(index);
}
@Override
public int getItemIndexForScroll(float progress) {
float depth = 0;
float totalDepth = getTotalDepth();
for (int i = 0; i < sectionHeights.size(); i++) {
depth += sectionHeights.get(i);
if (progress <= depth / totalDepth) {
return i;
}
}
return sectionHeights.size() - 1;
}
@Override
public int getTotalDepth() {
return getDepth(sectionHeights.size());
}
private int getDepth(int endIndex) {
int depth = 0;
for (int i = 0; i < endIndex; i++) {
depth += sectionHeights.get(i);
}
return depth;
}
Hello,
I've got a RecyclerView with multiple ViewHolders that all have a separate layout file with a different height (for example 20dp, 40dp and 60dp). So each row has a different (but static) height. When i use the TouchScrollBar it doesn't scroll smoothly trough the items. Is there a way to support this?