Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

ScrollToPosition issue! #353

Open
luifermoron opened this issue Nov 18, 2018 · 0 comments
Open

ScrollToPosition issue! #353

luifermoron opened this issue Nov 18, 2018 · 0 comments

Comments

@luifermoron
Copy link

When I execute the next code, the image header is not fully loaded.
` final int position = 0;
if (!(mRecyclerView.getLayoutManager() instanceof LinearLayoutManager)) return;
LinearLayoutManager layoutManager = (LinearLayoutManager)
mRecyclerView.getLayoutManager();
final int topItem = layoutManager.findFirstVisibleItemPosition();
final int distance = topItem - position;
int maxScroll = 10;
int anchorItem;
if (distance > maxScroll) anchorItem = position + maxScroll;
else if (distance < -maxScroll) anchorItem = position - maxScroll;
else anchorItem = topItem;
if (anchorItem != topItem) mRecyclerView.scrollToPosition(anchorItem);

            mRecyclerView.post(new Runnable() {
                @Override
                public void run() {
                    mRecyclerView.smoothScrollToPosition(position);
                }
            });`

12

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

1 participant