question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scroll TableView programmatically by the desired column position

See original GitHub issue

one 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:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
gmcodebustercommented, Jan 22, 2018

@evrencoskun ,

Thanks for adding scroll to position in recent release. I will integrate it in code and inform you about result.

1reaction
gmcodebustercommented, Jan 30, 2018

@evrencoskun, Scroll to position works perfectly.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found