Пример #1
0
        private int FitSize(int position, int left, bool scrollingUp)
        {
            int cellRight        = -1;
            int columnCacheWidth = mColumnHeaderLayoutManager.GetCacheWidth(position);

            Android.Views.View column = mColumnHeaderLayoutManager.FindViewByPosition(position);
            if (column != null)
            {
                // Determine default right
                cellRight = column.Left + columnCacheWidth + 1;
                if (scrollingUp)
                {
                    // Loop reverse order
                    for (int i = FindLastVisibleItemPosition(); i >= FindFirstVisibleItemPosition(); i--)
                    {
                        cellRight = Fit(position, i, left, cellRight, columnCacheWidth);
                    }
                }
                else
                {
                    // Loop for all rows which are visible.
                    for (int j = FindFirstVisibleItemPosition(); j < FindLastVisibleItemPosition() + 1; j++)
                    {
                        cellRight = Fit(position, j, left, cellRight, columnCacheWidth);
                    }
                }
            }
            else
            {
                Log.Error(LogTag, "Warning: column couldn't found for " + position);
            }

            return(cellRight);
        }
        public override void MeasureChild(Android.Views.View child, int widthUsed, int heightUsed)
        {
            int columnPosition = GetPosition(child);
            // Get cached width size of column and cell
            int cacheWidth       = mCellLayoutManager.GetCacheWidth(mYPosition, columnPosition);
            int columnCacheWidth = mColumnHeaderLayoutManager.GetCacheWidth(columnPosition);

            // Already each of them is same width size.
            if (cacheWidth != -1 && cacheWidth == columnCacheWidth)
            {
                // Control whether we need to set width or not.
                if (child.MeasuredWidth != cacheWidth)
                {
                    TableViewUtils.SetWidth(child, cacheWidth);
                }
            }
            else
            {
                Android.Views.View columnHeaderChild = mColumnHeaderLayoutManager.FindViewByPosition(columnPosition);
                if (columnHeaderChild == null)
                {
                    return;
                }

                // Need to calculate which one has the broadest width ?
                FitWidthSize(child, mYPosition, columnPosition, cacheWidth, columnCacheWidth, columnHeaderChild);
            }

            // Control all of the rows which has same column position.
            if (ShouldFitColumns(columnPosition, mYPosition))
            {
                if (mLastDx < 0)
                {
                    Log.Warn(LogTag, "x: " + columnPosition + " y: " + mYPosition + " fitWidthSize " + "left side ");
                    mCellLayoutManager.FitWidthSize(columnPosition, true);
                }
                else
                {
                    mCellLayoutManager.FitWidthSize(columnPosition, false);
                    Log.Warn(LogTag, "x: " + columnPosition + " y: " + mYPosition + " fitWidthSize " + "right side");
                }

                mNeedFitForVerticalScroll = false;
            }

            // It need to be cleared to prevent unnecessary calculation.
            mNeedFitForHorizontalScroll = false;
        }