Closed vkhaitan closed 5 years ago
I was trying to solve an issue that after changing the content of Table, I remeaserwidth and it works fine with content hugging width. However, Once I start scrolling, its width change after 1 row scroll. The new width is equal to the largest width table acquired in its existence(which means maximum width during data changes). Why so ?
I tried everything I could, but this cell width resize is still happening. Because of RemeasureWidth(), cell is resizing to fit requirements. However, during scroll its size increases to equal historical maximum size. How does TableView remember what was historical maximum size of TableView Column ?
Hi @vkhaitan,
Why do you need to use setHasFixedSize()
?, You shouldn't use the method which is for some performance control on RecyclerView. However, in TableView the size is not fixed. so you shouldn't use that. Please check this.
In TableView, The proper width value for each column is stored in TableView to be ready for new calculation at vertical scrolling process.
If you want to know, what's going on in the process, please check, ColumnWidthHandler, CellLayoutManager
if (childLayoutManager.isNeedFit()) {
// Scrolling up
if (mLastDy < 0) {
Log.e(LOG_TAG, position + " fitWidthSize all vertically up");
fitWidthSize(true);
} else {
// Scrolling down
Log.e(LOG_TAG, position + " fitWidthSize all vertically down");
fitWidthSize(false);
}
// all columns have been fitted.
childLayoutManager.clearNeedFit();
}
This function snippet is being called. Why isNeedFit() is true since I have already measuredProper columnWidth() ? My RemeasureColumnWidth() properly measures and gives correct width. However, during vertical scroll, aforementioned function is called and it gives historical maximum size. RemeasureColumnWidth() already removes cache, so that can't be issue. So, why it gets historical size and how ? I mean if old content is not present, they how does it get the old width ?
I am using this UI Element through Xamarin.Android . I ported it myself.
There is an issue which I am facing. setHasFixedSize() makes column and cell desynchronized. Columns has different width, cells have different width. So it becomes zigzag. In fact, all the cells in a column are of different width. I am also using RemeasureColumnWidth() .
This is the offending code - this.HasFixedWidth = true; // Removing this line fixes the issue. for (int i = 0; i < columnData.Count; ++i) { RemeasureColumnWidth(i); } Why would you allow cell to be desynchronized, it simply baffles me.