Skip to content

Commit a84bd90

Browse files
imhappipaulfthomas
authored andcommitted
[TabLayout] Fix issue with indicator not being drawn when viewpager starts scrolling before onLayout is called
PiperOrigin-RevId: 512062664 (cherry picked from commit 34d6a14)
1 parent 50b3d4f commit a84bd90

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/java/com/google/android/material/tabs/TabLayout.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3316,8 +3316,11 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
33163316
* in a viewpager.
33173317
*/
33183318
private void jumpIndicatorToPosition(int position) {
3319-
// Don't update the indicator position if the scroll state is not idle.
3320-
if (viewPagerScrollState != SCROLL_STATE_IDLE) {
3319+
// Don't update the indicator position if the scroll state is not idle, and the indicator
3320+
// is drawn.
3321+
if (viewPagerScrollState != SCROLL_STATE_IDLE
3322+
&& !(getTabSelectedIndicator().getBounds().left == -1
3323+
&& getTabSelectedIndicator().getBounds().right == -1)) {
33213324
return;
33223325
}
33233326
final View currentView = getChildAt(position);

0 commit comments

Comments
 (0)