Scroll TableView programmatically by the desired column position
See original GitHub issueone question: for your TableView library, how do you scroll to a column say column 20?
Hi @sidharthshah,
It is actually pretty simple. If you checked the source code, you can see TableView occurs from 3 Skilled RecyclerViews.
If you want to scroll horizontally, you can use scrollToPosition
method of LayoutManager.
For example:
int position = 10;
scrollCell(position);
scrollColumnHeader(position);
Below helper methods will be on the new version too. For now, you can insert them on your project.
private void scrollCell(int columnPosition) {
CellLayoutManager cellLayoutManager = tableView.getCellLayoutManager();
for (int i = cellLayoutManager.findFirstVisibleItemPosition(); i < cellLayoutManager
.findLastVisibleItemPosition() + 1; i++) {
ColumnLayoutManager columnLayoutManager = (ColumnLayoutManager) ((RecyclerView)
cellLayoutManager.findViewByPosition(i)).getLayoutManager();
columnLayoutManager.scrollToPosition(columnPosition);
}
}
private void scrollColumnHeader(int columnPosition) {
tableView.getColumnHeaderLayoutManager().scrollToPosition(columnPosition);
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
ios - Scroll View and Tableview programmatically alignment
I am implementing a UIScrollView which holds some user data. I am downloading additional data from my server. Once downloaded the contentSize of ......
Read more >Programmatic UITableView Scrolling - Grok Swift
We can opt to scroll so that the row is at the top of the view, the bottom, or the middle. There's also...
Read more >UITableview: The Essential Solution for Scrolling iOS Interfaces
A table view calculates the size and position of each item. In a scroll view, you need to figure the frame of each...
Read more >Configuring the cells for your table - Apple Developer
The table view asks for the heights of visible rows only. As the user scrolls, the table view asks you to provide the...
Read more >Table and TreeList View Scrolling in Code | WPF Controls
If the TableView.AutoWidth property is set to false and the number of columns is great, you can speed up the grid's performance by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@evrencoskun ,
Thanks for adding scroll to position in recent release. I will integrate it in code and inform you about result.
@evrencoskun, Scroll to position works perfectly.