예제 #1
0
        public LinearLayoutManager(int orientation)
        {
            mOrientation       = orientation;
            mOrientationHelper = OrientationHelper.CreateOrientationHelper(this, mOrientation);

            mLayoutState        = new LayoutState();
            mLayoutState.Offset = mOrientationHelper.GetStartAfterPadding();
        }
예제 #2
0
            public void ResetLayout(int direction, bool canUseExistingSpace, float space, OrientationHelper orientationHelper, LinearLayoutManager linearLayoutManager)
            {
                this.Extra           = 0;
                this.LayoutDirection = direction;

                float scrollingOffset = 0.0f;

                if (direction == LayoutState.LAYOUT_END)
                {
                    this.Extra += orientationHelper.GetEndPadding();
                    FlexibleViewViewHolder endChild = linearLayoutManager.GetChildClosestToEnd();
                    if (endChild != null)
                    {
                        // the direction in which we are traversing children
                        this.ItemDirection = linearLayoutManager.mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_HEAD
                                : LayoutState.ITEM_DIRECTION_TAIL;
                        this.CurrentPosition = endChild.LayoutPosition + linearLayoutManager.mLayoutState.ItemDirection;
                        this.Offset          = orientationHelper.GetViewHolderEnd(endChild);
                        scrollingOffset      = orientationHelper.GetViewHolderEnd(endChild) - orientationHelper.GetEndAfterPadding();
                    }
                }
                else
                {
                    this.Extra += orientationHelper.GetStartAfterPadding();
                    FlexibleViewViewHolder startChild = linearLayoutManager.GetChildClosestToStart();
                    if (startChild != null)
                    {
                        this.ItemDirection = linearLayoutManager.mShouldReverseLayout ? LayoutState.ITEM_DIRECTION_TAIL
                                : LayoutState.ITEM_DIRECTION_HEAD;
                        this.CurrentPosition = startChild.LayoutPosition + linearLayoutManager.mLayoutState.ItemDirection;
                        this.Offset          = orientationHelper.GetViewHolderStart(startChild);
                        scrollingOffset      = -orientationHelper.GetViewHolderStart(startChild) + orientationHelper.GetStartAfterPadding();
                    }
                }

                this.Available = space;

                if (canUseExistingSpace)
                {
                    this.Available -= scrollingOffset;
                }
                this.ScrollingOffset = scrollingOffset;
            }