private void Fit2(int xPosition, int yPosition, int columnCachedWidth, Android.Views.View column, ColumnLayoutManager childLayoutManager) { int cellCacheWidth = GetCacheWidth(yPosition, xPosition); Android.Views.View cell = childLayoutManager.FindViewByPosition(xPosition); // Control whether the cell needs to be fitted by column header or not. if (cell != null) { if (cellCacheWidth != columnCachedWidth || mNeedSetLeft) { // This is just for setting width value if (cellCacheWidth != columnCachedWidth) { cellCacheWidth = columnCachedWidth; TableViewUtils.SetWidth(cell, cellCacheWidth); SetCacheWidth(yPosition, xPosition, cellCacheWidth); } // The left & right values of Column header can be considered. Because this // method will be worked // after drawing process of main thread. if (column.Left != cell.Left || column.Right != cell.Right) { // TODO: + 1 is for decoration item. It should be gotten from a generic // method of layoutManager // Set right & left values cell.Left = column.Left; cell.Right = column.Right + 1; childLayoutManager.LayoutDecoratedWithMargins(cell, cell.Left, cell.Top, cell.Right, cell.Bottom); mNeedSetLeft = true; } } } }
private int Fit(int xPosition, int yPosition, int left, int right, int columnCachedWidth) { CellRecyclerView child = (CellRecyclerView)FindViewByPosition(yPosition); if (child != null) { ColumnLayoutManager childLayoutManager = (ColumnLayoutManager)child.GetLayoutManager(); int cellCacheWidth = GetCacheWidth(yPosition, xPosition); Android.Views.View cell = childLayoutManager.FindViewByPosition(xPosition); // Control whether the cell needs to be fitted by column header or not. if (cell != null) { if (cellCacheWidth != columnCachedWidth || mNeedSetLeft) { // This is just for setting width value if (cellCacheWidth != columnCachedWidth) { cellCacheWidth = columnCachedWidth; TableViewUtils.SetWidth(cell, cellCacheWidth); SetCacheWidth(yPosition, xPosition, cellCacheWidth); } // Even if the cached values are same, the left & right value wouldn't change. // mNeedSetLeft & the below lines for it. if (left != IgnoreLeft && cell.Left != left) { // Calculate scroll distance int scrollX = Math.Max(cell.Left, left) - Math.Min(cell.Left, left); // Update its left cell.Left = left; int offset = mHorizontalListener.GetScrollPositionOffset(); // It shouldn't be scroll horizontally and the problem is gotten just for // first visible item. if (offset > 0 && xPosition == childLayoutManager.FindFirstVisibleItemPosition() && mCellRecyclerView.ScrollState != RecyclerView.ScrollStateIdle) { int scrollPosition = mHorizontalListener.GetScrollPosition(); offset = mHorizontalListener.GetScrollPositionOffset() + scrollX; // Update scroll position offset value mHorizontalListener.SetScrollPositionOffset(offset); // Scroll considering to the desired value. childLayoutManager.ScrollToPositionWithOffset(scrollPosition, offset); } } if (cell.Width != cellCacheWidth) { if (left != IgnoreLeft) { // TODO: + 1 is for decoration item. It should be gotten from a // generic method of layoutManager // Set right right = cell.Left + cellCacheWidth + 1; cell.Right = right; childLayoutManager.LayoutDecoratedWithMargins(cell, cell.Left, cell.Top, cell.Right, cell.Bottom); } mNeedSetLeft = true; } } } } return(right); }