Skip to content

Commit 74b7706

Browse files
pubiqqhunterstich
authored andcommitted
[ShapeableImageView] Don't change layer type when view is detached from the window
When the exit transition starts, the layer type is set to LAYER_TYPE_NONE (inside onDetachedFromWindow). In this case, clearPaint (Paint with Xfermode = PorterDuff.Mode.DST_OUT) stops working correctly. The patch just deletes the layer type setup from onDetachedFromWindow, leaving the layer type set to LAYER_TYPE_HARDWARE. Resolves #2703 Resolves #2792 GIT_ORIGIN_REV_ID=b05230b40529251b8b16cc02f1cfd64f3801c1d8 PiperOrigin-RevId: 459308833
1 parent 51c59fa commit 74b7706

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

lib/java/com/google/android/material/imageview/ShapeableImageView.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public ShapeableImageView(Context context, @Nullable AttributeSet attrs, int def
108108
context.obtainStyledAttributes(
109109
attrs, R.styleable.ShapeableImageView, defStyle, DEF_STYLE_RES);
110110

111+
setLayerType(LAYER_TYPE_HARDWARE, null);
112+
111113
strokeColor =
112114
MaterialResources.getColorStateList(
113115
context, attributes, R.styleable.ShapeableImageView_strokeColor);
@@ -150,18 +152,6 @@ public ShapeableImageView(Context context, @Nullable AttributeSet attrs, int def
150152
}
151153
}
152154

153-
@Override
154-
protected void onDetachedFromWindow() {
155-
setLayerType(LAYER_TYPE_NONE, null);
156-
super.onDetachedFromWindow();
157-
}
158-
159-
@Override
160-
protected void onAttachedToWindow() {
161-
super.onAttachedToWindow();
162-
setLayerType(LAYER_TYPE_HARDWARE, null);
163-
}
164-
165155
@Override
166156
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
167157
super.onMeasure(widthMeasureSpec, heightMeasureSpec);

0 commit comments

Comments
 (0)