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.

[TabLayout] setScrollPosition is not working correctly

See original GitHub issue

Calling setScrollPosition() with updateSelectedText = true and updateIndicatorPosition = true doesn’t set the indicator to the specified position:

Actual result Expected result

Material Library version: 1.8.0-alpha03

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
imhappicommented, Nov 24, 2022

Ah I see that the onLayout call isn’t expected and is caused by updating the tab visuals to the view selection

I do agree that although this method really shouldn’t be being used, the previous behavior should be re-instated, will re-open this issue and look into this more closely after the holidays

0reactions
pubiqqcommented, Nov 24, 2022

If your logic is correct, why do you need updateIndicatorPosition at all if it is ignored, and the position of the indicator is updated in onLayout() anyway?

I agree, the method has a very unfortunate name, it has a dual purpose, has some problems with documentation, etc. But this method used to work properly, and I think consumers expect it to continue to work or some alternative will be given.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to scroll tablayout programmatically - Android
So first three tabs are visible on screen and rest of them are invisible which can be scroll using swipe gesture. The problem...
Read more >
TabLayout | Android Developers
Sets the tab indicator's color for the currently selected tab. If the tab indicator color is not Color.TRANSPARENT , the indicator will be ......
Read more >
com.google.android.material.tabs.TabLayout.setScrollPosition ...
Best Java code snippets using com.google.android.material.tabs.TabLayout.setScrollPosition (Showing top 3 results out of 315).
Read more >
Tab click not working after swipe [37057275] - Issue Tracker
Have a viewpager + tablayout. When you swipe the viewpager, then click on the previous tab, the viewpager doesn't scroll to the new...
Read more >
bug: setCurrentItem() does not scroll tab to proper position #10
the content is fine, it shows the tabToSelect fragment. however the tablayout is not scrolling and still showing original position.
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