コード例 #1
0
        // Used by the renderer to maintain scroll offset when using ItemsUpdatingScrollMode KeepScrollOffset
        public void UndoNextScrollAdjustment()
        {
            // Don't start tracking the scroll offsets until we really need to
            if (!_maintainingScrollOffsets)
            {
                _maintainingScrollOffsets = true;
                _recyclerView.AddOnScrollListener(this);
            }

            _undoNextScrollAdjustment = true;

            _lastScrollX = _recyclerView.ComputeHorizontalScrollOffset();
            _lastScrollY = _recyclerView.ComputeVerticalScrollOffset();
        }
コード例 #2
0
            public void CenterIfNeeded(RecyclerView recyclerView, bool isHorizontal)
            {
                if (!(recyclerView.GetLayoutManager() is LinearLayoutManager linearLayoutManager))
                {
                    return;
                }

                var itemSourceCount = _itemsSource.Count;

                var firstCompletelyItemVisible = linearLayoutManager.FindFirstCompletelyVisibleItemPosition();

                var offSet = recyclerView.ComputeHorizontalScrollOffset();

                if (!isHorizontal)
                {
                    offSet = recyclerView.ComputeVerticalScrollOffset();
                }

                if (firstCompletelyItemVisible == 0)
                {
                    linearLayoutManager.ScrollToPositionWithOffset(itemSourceCount, -offSet);
                }
            }