Skip to content

Commit df61bff

Browse files
cketchamdsn5ft
authored andcommitted
Fixed halo rendering bug for Slider
Using a hardware layer was causing problems in some versions of Android when drawing the halo ripple. Hardware layer really only needs to be used when the slider is disabled. PiperOrigin-RevId: 286640042
1 parent e38d260 commit df61bff

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,6 @@ public Slider(@NonNull Context context, @Nullable AttributeSet attrs, int defSty
296296
loadResources(context.getResources());
297297
processAttributes(context, attrs, defStyleAttr);
298298

299-
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
300-
// Because the RippleDrawable can draw outside the bounds of the view, we can set the layer
301-
// type to hardware so we can use PorterDuffXfermode when drawing.
302-
setLayerType(LAYER_TYPE_HARDWARE, null);
303-
}
304-
305299
super.setOnFocusChangeListener(
306300
new OnFocusChangeListener() {
307301
@Override
@@ -1025,12 +1019,8 @@ public void setTrackColorInactive(@NonNull ColorStateList trackColor) {
10251019
public void setEnabled(boolean enabled) {
10261020
super.setEnabled(enabled);
10271021
// When we're disabled, set the layer type to hardware so we can clear the track out from behind
1028-
// the thumb. When enabled set the layer type to none so that the halo can be drawn outside the
1029-
// bounds of the slider. After Lollipop we use Ripple for the halo, and an Overlay for the
1030-
// marker so we don't need to worry about drawing outside the bounds.
1031-
if (VERSION.SDK_INT < VERSION_CODES.LOLLIPOP) {
1032-
setLayerType(enabled ? LAYER_TYPE_NONE : LAYER_TYPE_HARDWARE, null);
1033-
}
1022+
// the thumb.
1023+
setLayerType(enabled ? LAYER_TYPE_NONE : LAYER_TYPE_HARDWARE, null);
10341024
}
10351025

10361026
@Override

0 commit comments

Comments
 (0)