Skip to content

Commit 967dcd5

Browse files
manabu-nakamuraimhappi
authored andcommitted
[Slider] Fix slider label not moving
Resolves #4104 GIT_ORIGIN_REV_ID=676308a77b429610192b1df80becb656e6053811 PiperOrigin-RevId: 666511279
1 parent 1795035 commit 967dcd5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/java/com/google/android/material/slider/BaseSlider.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ abstract class BaseSlider<
349349
@NonNull
350350
private final ViewTreeObserver.OnScrollChangedListener onScrollChangedListener =
351351
this::updateLabels;
352+
@NonNull
353+
private final ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener =
354+
this::updateLabels;
352355

353356
/**
354357
* Determines the behavior of the label which can be any of the following.
@@ -1883,6 +1886,7 @@ public void setEnabled(boolean enabled) {
18831886
protected void onAttachedToWindow() {
18841887
super.onAttachedToWindow();
18851888
getViewTreeObserver().addOnScrollChangedListener(onScrollChangedListener);
1889+
getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);
18861890
// The label is attached on the Overlay relative to the content.
18871891
for (TooltipDrawable label : labels) {
18881892
attachLabelToContentView(label);
@@ -1904,6 +1908,7 @@ protected void onDetachedFromWindow() {
19041908
detachLabelFromContentView(label);
19051909
}
19061910
getViewTreeObserver().removeOnScrollChangedListener(onScrollChangedListener);
1911+
getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayoutListener);
19071912
super.onDetachedFromWindow();
19081913
}
19091914

0 commit comments

Comments
 (0)