Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

firstVisiblePosition 获取到的总是1 #41

Open
ghost opened this issue Dec 7, 2018 · 1 comment
Open

firstVisiblePosition 获取到的总是1 #41

ghost opened this issue Dec 7, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 7, 2018

在滚动后再回滚到列表开始位置,然后调用firstVisiblePosition 获取到的总是1而不是0

@ghost
Copy link
Author

ghost commented Dec 7, 2018

SpannedGridLayoutManager layoutManager = new
SpannedGridLayoutManager(SpannedGridLayoutManager.Orientation.HORIZONTAL, 4);
layoutManager.setItemOrderIsStable(true);
layoutManager.setSpanSizeLookup(new SpannedGridLayoutManager.SpanSizeLookup(new
Function1<Integer, SpanSize>(){
@OverRide public SpanSize invoke(Integer position) {
final int span1 = (position == 0 || position == 6 || position == 13 || position == 5 ? 2 : 1);
final int span2 = (position == 0 || position == 6 || position == 13 ? 2 : position == 5 ? 4 : 1);
return new SpanSize(span1, span2);
}
}));
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.addItemDecoration(new SpaceItemDecorator(5, 5, 5, 5));

    mAdapter = new SpannedAdapter(getContext(), mRecyclerView);
    mAdapter.setDatas(ItemDatas.getDatas(60));
    mRecyclerView.setAdapter(mAdapter);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants