Exemple #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();
        }
            public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
            {
                base.OnScrolled(recyclerView, dx, dy);

                if (scrolledY == int.MinValue)
                {
                    var child             = recyclerView.GetChildAt(0);
                    var positionFirstItem = recyclerView.GetChildAdapterPosition(child);
                    var heightDecorator   = positionFirstItem == 0 ? 0 : headerView.heightHeader;
                    var offset            = recyclerView.ComputeVerticalScrollOffset();
                    scrolledY = offset + heightDecorator;
                }
                else
                {
                    scrolledY += dy;
                }

                headerView.headerAnimator.OnScroll(-scrolledY);
            }
Exemple #3
0
        public static bool CanScroll(View view)
        {
            ScrollView scrollView = view as ScrollView;

            if (scrollView != null)
            {
                View child = scrollView.GetChildAt(0);
                if (child == null)
                {
                    return(false);
                }

                return(scrollView.Height < child.Height + scrollView.PaddingTop + scrollView.PaddingBottom);
            }
            RecyclerView recyclerView = view as RecyclerView;

            if (recyclerView != null)
            {
                return(recyclerView.ComputeVerticalScrollOffset() != 0);
            }
            return(true);
        }
            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);
                }
            }
			public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
			{
				base.OnScrolled(recyclerView, dx, dy);
				
				if (scrolledY == int.MinValue)
				{
					var child = recyclerView.GetChildAt(0);
					var positionFirstItem = recyclerView.GetChildAdapterPosition(child);
					var heightDecorator = positionFirstItem == 0 ? 0 : headerView.heightHeader;
					var offset = recyclerView.ComputeVerticalScrollOffset();
					scrolledY = offset + heightDecorator;
				}
				else
				{
					scrolledY += dy;
				}

				headerView.headerAnimator.OnScroll(-scrolledY);
			}