diff --git a/lib/java/com/google/android/material/imageview/ShapeableImageView.java b/lib/java/com/google/android/material/imageview/ShapeableImageView.java index ff27775f151..0dccd0d4bae 100644 --- a/lib/java/com/google/android/material/imageview/ShapeableImageView.java +++ b/lib/java/com/google/android/material/imageview/ShapeableImageView.java @@ -108,6 +108,8 @@ public ShapeableImageView(Context context, @Nullable AttributeSet attrs, int def context.obtainStyledAttributes( attrs, R.styleable.ShapeableImageView, defStyle, DEF_STYLE_RES); + setLayerType(LAYER_TYPE_HARDWARE, null); + strokeColor = MaterialResources.getColorStateList( context, attributes, R.styleable.ShapeableImageView_strokeColor); @@ -150,18 +152,6 @@ public ShapeableImageView(Context context, @Nullable AttributeSet attrs, int def } } - @Override - protected void onDetachedFromWindow() { - setLayerType(LAYER_TYPE_NONE, null); - super.onDetachedFromWindow(); - } - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - setLayerType(LAYER_TYPE_HARDWARE, null); - } - @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec);