Skip to content

Commit

Permalink
[TabLayout] Fix issue with indicator not being drawn when viewpager s…
Browse files Browse the repository at this point in the history
…tarts scrolling before onLayout is called

PiperOrigin-RevId: 512062664
  • Loading branch information
imhappi authored and paulfthomas committed Feb 27, 2023
1 parent f3d8c31 commit 34d6a14
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/java/com/google/android/material/tabs/TabLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -3316,8 +3316,11 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
* in a viewpager.
*/
private void jumpIndicatorToPosition(int position) {
// Don't update the indicator position if the scroll state is not idle.
if (viewPagerScrollState != SCROLL_STATE_IDLE) {
// Don't update the indicator position if the scroll state is not idle, and the indicator
// is drawn.
if (viewPagerScrollState != SCROLL_STATE_IDLE
&& !(getTabSelectedIndicator().getBounds().left == -1
&& getTabSelectedIndicator().getBounds().right == -1)) {
return;
}
final View currentView = getChildAt(position);
Expand Down

0 comments on commit 34d6a14

Please sign in to comment.