@Test public void scrollAndClear() throws Throwable { setupByConfig(new Config(), true); assertTrue("Children not laid out", mLayoutManager.collectChildCoordinates().size() > 0); mLayoutManager.expectLayouts(1); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { mLayoutManager.scrollToPositionWithOffset(1, 0); mTestAdapter.clearOnUIThread(); } }); mLayoutManager.waitForLayout(2); assertEquals("Remaining children", 0, mLayoutManager.collectChildCoordinates().size()); }
public void scrollToPositionWithOffset(int position, int offset) { mPendingScrollPosition = position; mPendingScrollPositionOffset = offset; if (mPendingSavedState != null) { mPendingSavedState.invalidateAnchor(); } requestLayout(); }
LinearLayoutManager extends RecyclerView.LayoutManager implements
        ItemTouchHelper.ViewDropHandler, RecyclerView.SmoothScroller.ScrollVectorProvider { public void scrollToPositionWithOffset(int position, int offset) { mPendingScrollPosition = position; mPendingScrollPositionOffset = offset; if (mPendingSavedState != null) { mPendingSavedState.invalidateAnchor(); } requestLayout(); } }
LinearLayoutManager extends RecyclerView.LayoutManager implements
        ItemTouchHelper.ViewDropHandler, RecyclerView.SmoothScroller.ScrollVectorProvider { public void scrollToPositionWithOffset(int position, int offset) { mPendingScrollPosition = position; mPendingScrollPositionOffset = offset; if (mPendingSavedState != null) { mPendingSavedState.invalidateAnchor(); } requestLayout(); } LinearLayoutManager(Context context);  LinearLayoutManager(Context context, @RecyclerView.Orientation int orientation,
            boolean reverseLayout);  LinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes); }
LinearLayoutManager extends RecyclerView.LayoutManager implements
        ItemTouchHelper.ViewDropHandler, RecyclerView.SmoothScroller.ScrollVectorProvider { public void scrollToPositionWithOffset(int position, int offset) { mPendingScrollPosition = position; mPendingScrollPositionOffset = offset; if (mPendingSavedState != null) { mPendingSavedState.invalidateAnchor(); } requestLayout(); } LinearLayoutManager(Context context);  LinearLayoutManager(Context context, @RecyclerView.Orientation int orientation,
            boolean reverseLayout);  LinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes); @Override boolean isAutoMeasureEnabled(); @Override RecyclerView.LayoutParams generateDefaultLayoutParams(); boolean getRecycleChildrenOnDetach(); void setRecycleChildrenOnDetach(boolean recycleChildrenOnDetach); @Override void onDetachedFromWindow(RecyclerView view, RecyclerView.Recycler recycler); @Override void onInitializeAccessibilityEvent(AccessibilityEvent event); @Override Parcelable onSaveInstanceState(); @Override void onRestoreInstanceState(Parcelable state); @Override boolean canScrollHorizontally(); @Override boolean canScrollVertically(); void setStackFromEnd(boolean stackFromEnd); boolean getStackFromEnd(); @RecyclerView.Orientation int getOrientation(); void setOrientation(@RecyclerView.Orientation int orientation); boolean getReverseLayout(); void setReverseLayout(boolean reverseLayout); @Override View findViewByPosition(int position); @Override void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state,
            int position); @Override PointF computeScrollVectorForPosition(int targetPosition); @Override void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state); @Override void onLayoutCompleted(RecyclerView.State state); @Override void scrollToPosition(int position); void scrollToPositionWithOffset(int position, int offset); @Override int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override int computeHorizontalScrollOffset(RecyclerView.State state); @Override int computeVerticalScrollOffset(RecyclerView.State state); @Override int computeHorizontalScrollExtent(RecyclerView.State state); @Override int computeVerticalScrollExtent(RecyclerView.State state); @Override int computeHorizontalScrollRange(RecyclerView.State state); @Override int computeVerticalScrollRange(RecyclerView.State state); void setSmoothScrollbarEnabled(boolean enabled); boolean isSmoothScrollbarEnabled(); @Override void collectInitialPrefetchPositions(int adapterItemCount,
            LayoutPrefetchRegistry layoutPrefetchRegistry); void setInitialPrefetchItemCount(int itemCount); int getInitialPrefetchItemCount(); @Override void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state,
            LayoutPrefetchRegistry layoutPrefetchRegistry); @Override void assertNotInLayoutOrScroll(String message); int findFirstVisibleItemPosition(); int findFirstCompletelyVisibleItemPosition(); int findLastVisibleItemPosition(); int findLastCompletelyVisibleItemPosition(); @Override View onFocusSearchFailed(View focused, int focusDirection,
            RecyclerView.Recycler recycler, RecyclerView.State state); @Override boolean supportsPredictiveItemAnimations(); @RestrictTo(LIBRARY_GROUP) @Override void prepareForDrop(@NonNull View view, @NonNull View target, int x, int y); }
LinearLayoutManager extends RecyclerView.LayoutManager implements
        ItemTouchHelper.ViewDropHandler, RecyclerView.SmoothScroller.ScrollVectorProvider { public void scrollToPositionWithOffset(int position, int offset) { mPendingScrollPosition = position; mPendingScrollPositionOffset = offset; if (mPendingSavedState != null) { mPendingSavedState.invalidateAnchor(); } requestLayout(); } LinearLayoutManager(Context context);  LinearLayoutManager(Context context, @RecyclerView.Orientation int orientation,
            boolean reverseLayout);  LinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes); @Override boolean isAutoMeasureEnabled(); @Override RecyclerView.LayoutParams generateDefaultLayoutParams(); boolean getRecycleChildrenOnDetach(); void setRecycleChildrenOnDetach(boolean recycleChildrenOnDetach); @Override void onDetachedFromWindow(RecyclerView view, RecyclerView.Recycler recycler); @Override void onInitializeAccessibilityEvent(AccessibilityEvent event); @Override Parcelable onSaveInstanceState(); @Override void onRestoreInstanceState(Parcelable state); @Override boolean canScrollHorizontally(); @Override boolean canScrollVertically(); void setStackFromEnd(boolean stackFromEnd); boolean getStackFromEnd(); @RecyclerView.Orientation int getOrientation(); void setOrientation(@RecyclerView.Orientation int orientation); boolean getReverseLayout(); void setReverseLayout(boolean reverseLayout); @Override View findViewByPosition(int position); @Override void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state,
            int position); @Override PointF computeScrollVectorForPosition(int targetPosition); @Override void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state); @Override void onLayoutCompleted(RecyclerView.State state); @Override void scrollToPosition(int position); void scrollToPositionWithOffset(int position, int offset); @Override int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler,
            RecyclerView.State state); @Override int computeHorizontalScrollOffset(RecyclerView.State state); @Override int computeVerticalScrollOffset(RecyclerView.State state); @Override int computeHorizontalScrollExtent(RecyclerView.State state); @Override int computeVerticalScrollExtent(RecyclerView.State state); @Override int computeHorizontalScrollRange(RecyclerView.State state); @Override int computeVerticalScrollRange(RecyclerView.State state); void setSmoothScrollbarEnabled(boolean enabled); boolean isSmoothScrollbarEnabled(); @Override void collectInitialPrefetchPositions(int adapterItemCount,
            LayoutPrefetchRegistry layoutPrefetchRegistry); void setInitialPrefetchItemCount(int itemCount); int getInitialPrefetchItemCount(); @Override void collectAdjacentPrefetchPositions(int dx, int dy, RecyclerView.State state,
            LayoutPrefetchRegistry layoutPrefetchRegistry); @Override void assertNotInLayoutOrScroll(String message); int findFirstVisibleItemPosition(); int findFirstCompletelyVisibleItemPosition(); int findLastVisibleItemPosition(); int findLastCompletelyVisibleItemPosition(); @Override View onFocusSearchFailed(View focused, int focusDirection,
            RecyclerView.Recycler recycler, RecyclerView.State state); @Override boolean supportsPredictiveItemAnimations(); @RestrictTo(LIBRARY_GROUP) @Override void prepareForDrop(@NonNull View view, @NonNull View target, int x, int y); static final int HORIZONTAL; static final int VERTICAL; static final int INVALID_OFFSET; }