car/src/main/java/androidx/car/widget/PagedListView.java
public void pageDown() {
        if (mRecyclerView.getLayoutManager() == null || mRecyclerView.getChildCount() == 0) {
            return;
        }

        OrientationHelper orientationHelper =
                getOrientationHelper(mRecyclerView.getLayoutManager());
        int screenSize = mRecyclerView.getHeight();
        int scrollDistance = screenSize;

        // If the last item is partially visible, page down should bring it to the top.
        View lastChild = mRecyclerView.getChildAt(mRecyclerView.getChildCount() - 1);
        if (mRecyclerView.getLayoutManager().isViewPartiallyVisible(lastChild,
                /* completelyVisible= */ false, /* acceptEndPointInclusion= */ false)) {
            scrollDistance = orientationHelper.getDecoratedStart(lastChild);
            if (scrollDistance < 0) {
                // Scroll value can be negative if the child is longer than the screen size and the
                // visible area of the screen does not show the start of the child.
                // Scroll to the next screen if the start value is negative
                scrollDistance = screenSize;
            }
        }

        // The iteration order matters. In case where there are 2 items longer than screen size, we
        // want to focus on upcoming view (the one at the bottom of screen).
        for (int i = mRecyclerView.getChildCount() - 1; i >= 0; i--) {
            /* We treat child View longer than screen size differently:
             * 1) When it enters screen, next pageDown will align its top with parent top;
             * 2) When it leaves screen, next pageDown will align its bottom with parent bottom.
             */
            View child = mRecyclerView.getChildAt(i);
            if (child.getHeight() > screenSize) {
                if (orientationHelper.getDecoratedStart(child) > 0) {
                    // Child view top is entering screen. Align its top with parent top.
                    scrollDistance = orientationHelper.getDecoratedStart(child);
                } else if (screenSize < orientationHelper.getDecoratedEnd(child)
                        && orientationHelper.getDecoratedEnd(child) < 2 * screenSize) {
                    // Child view bottom is about to enter screen - its distance to parent bottom
                    // is less than a full scroll. Align child bottom with parent bottom.
                    scrollDistance = orientationHelper.getDecoratedEnd(child) - screenSize;
                }
                // There can be two items that are longer than the screen. We stop at the first one.
                // This is affected by the iteration order.
                break;
            }
        }

        mRecyclerView.smoothScrollBy(0, scrollDistance);
    }
/**
     * Scrolls the contents of the RecyclerView down a page. A page is defined as the height of the
     * {@code PagedListView}.
     *
     * <p>This method will attempt to bring the last item in the list as the first item. If the
     * current first item in the list is taller than the {@code PagedListView}, then it will be
     * scrolled the length of a page, but not snapped to.
     */
Scrolls the contents of the RecyclerView down a page. A page is defined as the height of the
PagedListView.

This method will attempt to bring the last item in the list as the first item. If the
current first item in the list is taller than the  PagedListView, then it will be
scrolled the length of a page, but not snapped to.
Scrolls the contents of the RecyclerView down a page . A page is defined as the height of the PagedListView . This method will attempt to bring the last item in the list as the first item . If the current first item in the list is taller than the PagedListView then it will be scrolled the length of a page but not snapped to .
public void pageDown() {
        if (mRecyclerView.getLayoutManager() == null || mRecyclerView.getChildCount() == 0) {
            return;
        }
        OrientationHelper orientationHelper =
                getOrientationHelper(mRecyclerView.getLayoutManager());
        int screenSize = mRecyclerView.getHeight();
        int scrollDistance = screenSize;
        View lastChild = mRecyclerView.getChildAt(mRecyclerView.getChildCount() - 1);
        if (mRecyclerView.getLayoutManager().isViewPartiallyVisible(lastChild,
                /* completelyVisible= */ false, /* acceptEndPointInclusion= */ false)) {
            scrollDistance = orientationHelper.getDecoratedStart(lastChild);
            if (scrollDistance < 0) {
                scrollDistance = screenSize;
            }
        }
        for (int i = mRecyclerView.getChildCount() - 1; i >= 0; i--) {
            /* We treat child View longer than screen size differently:
             * 1) When it enters screen, next pageDown will align its top with parent top;
             * 2) When it leaves screen, next pageDown will align its bottom with parent bottom.
             */
            View child = mRecyclerView.getChildAt(i);
            if (child.getHeight() > screenSize) {
                if (orientationHelper.getDecoratedStart(child) > 0) {
                    scrollDistance = orientationHelper.getDecoratedStart(child);
                } else if (screenSize < orientationHelper.getDecoratedEnd(child)
                        && orientationHelper.getDecoratedEnd(child) < 2 * screenSize) {
                    scrollDistance = orientationHelper.getDecoratedEnd(child) - screenSize;
                }
                break;
            }
        }
        mRecyclerView.smoothScrollBy(0, scrollDistance);
    }
public void pageDown ( ) { if ( mRecyclerView . getLayoutManager ( ) == null || mRecyclerView . getChildCount ( ) == 0 ) { return ; } OrientationHelper orientationHelper = getOrientationHelper ( mRecyclerView . getLayoutManager ( ) ) ; int screenSize = mRecyclerView . getHeight ( ) ; int scrollDistance = screenSize ; View lastChild = mRecyclerView . getChildAt ( mRecyclerView . getChildCount ( ) - 1 ) ; if ( mRecyclerView . getLayoutManager ( ) . isViewPartiallyVisible ( lastChild , /* completelyVisible= */ false , /* acceptEndPointInclusion= */ false ) ) { scrollDistance = orientationHelper . getDecoratedStart ( lastChild ) ; if ( scrollDistance < 0 ) { scrollDistance = screenSize ; } } for ( int i = mRecyclerView . getChildCount ( ) - 1 ; i >= 0 ; i -- ) { /* We treat child View longer than screen size differently:
             * 1) When it enters screen, next pageDown will align its top with parent top;
             * 2) When it leaves screen, next pageDown will align its bottom with parent bottom.
             */ View child = mRecyclerView . getChildAt ( i ) ; if ( child . getHeight ( ) > screenSize ) { if ( orientationHelper . getDecoratedStart ( child ) > 0 ) { scrollDistance = orientationHelper . getDecoratedStart ( child ) ; } else if ( screenSize < orientationHelper . getDecoratedEnd ( child ) && orientationHelper . getDecoratedEnd ( child ) < 2 * screenSize ) { scrollDistance = orientationHelper . getDecoratedEnd ( child ) - screenSize ; } break ; } } mRecyclerView . smoothScrollBy ( 0 , scrollDistance ) ; }
Scrolls the contents of the RecyclerView down a page.
Scrolls the contents of the RecyclerView down a page .
// If the last item is partially visible, page down should bring it to the top. // Scroll value can be negative if the child is longer than the screen size and the // visible area of the screen does not show the start of the child. // Scroll to the next screen if the start value is negative // The iteration order matters. In case where there are 2 items longer than screen size, we // want to focus on upcoming view (the one at the bottom of screen). // Child view top is entering screen. Align its top with parent top. // Child view bottom is about to enter screen - its distance to parent bottom // is less than a full scroll. Align child bottom with parent bottom. // There can be two items that are longer than the screen. We stop at the first one. // This is affected by the iteration order.