Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MaterialSwitch] Fix drawable scaling for API < 23 #3513

Closed

Conversation

pubiqq
Copy link
Contributor

@pubiqq pubiqq commented Aug 8, 2023

No description provided.

@@ -293,8 +293,7 @@ public static Drawable compositeTwoLayeredDrawable(
drawable.setLayerGravity(1, Gravity.CENTER);
} else {
Drawable scaledTopLayerDrawable =
new ScaledDrawableWrapper(topLayerDrawable, topLayerNewWidth, topLayerNewHeight)
.getDrawable();
new ScaledDrawableWrapper(topLayerDrawable, topLayerNewWidth, topLayerNewHeight);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pubiqq! Can you provide some more information:

  • More description of the issue pre API level 23
  • Before and After screenshots
  • Explanation around why removing the .getDrawable() fixes it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is incorrect because a wrapped drawable (topLayerDrawable) is used instead of a wrapper (scaled topLayerDrawable).

We're using ScaledDrawableWrapper here to get a scaled topLayerDrawable on pre-23 API (on API 23 and above we are using built-in LayerDrawable.setLayerSize() for this).

@pubiqq pubiqq requested a review from dsn5ft August 17, 2023 22:11
@leticiarossi leticiarossi added the Reviewing Internally An internal change has been created and sent for review. label Sep 6, 2023
@leticiarossi leticiarossi removed the Reviewing Internally An internal change has been created and sent for review. label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants