-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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] Amendments to thumb icon size support #3364
Conversation
Thanks for providing a solution on API < 23. For other parts of the change:
|
Will that suit your team?
|
|
I'm afraid I have no idea what you mean at all.
Both ways make sense. I would just like to keep the naming uniformity, and that's why I would like to keep
We have an implementation of the switch icon and it's already supported by
We already have an implementation of the icon and its size doesn't meet the specification. The proposal fixes this flaw.
We have to do this and all material components are doing this, because it's part of the specification. If the client wants to change the icon size, they can use the appropriate attribute or method. |
I mean, You can imagine that the And - I think separating width/height makes more sense than a single size attribute because it provides better flexibility. And if we have width/height, it doesn't make sense to have size as well since it's redundant. No matter what, it's just my personal opinion. If you still disagree let's involve @dsn5ft to hear more thoughts from a different perspective here. : ) |
also don't provide any icons, but do provide default size for them. I understand your point and agree with it: having Anyway, yeah, let's get @dsn5ft's opinion. |
Hi @pubiqq, I'm filling in for @dsn5ft at the moment. @drchen and I spoke about this and I think we're going to work on getting this in before 1.10 goes to beta. It's a little unfortunate to have to cherry pick this in to our release so late but we agree on I'm going to try to resolve the breaking changes internally and will get back to you. Hunter |
drawable.setLayerGravity(1, Gravity.CENTER); | ||
} else { | ||
Drawable scaledTopLayerDrawable = | ||
new ScaledDrawableWrapper(topLayerDrawable, topLayerNewWidth, topLayerNewHeight); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires API >= 23, see https://developer.android.com/reference/android/graphics/drawable/DrawableWrapper so cannot be used here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is executed only in API >= 23:
material-components-android/lib/java/com/google/android/material/drawable/DrawableUtils.java
Lines 289 to 294 in 58f5439
if (VERSION.SDK_INT >= VERSION_CODES.M) { | |
drawable = new LayerDrawable(new Drawable[] {bottomLayerDrawable, topLayerDrawable}); | |
drawable.setLayerSize(1, topLayerNewWidth, topLayerNewHeight); | |
drawable.setLayerGravity(1, Gravity.CENTER); | |
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm talking about ScaledDrawableWrapper
which extends DrawableWrapper
which is only API >= 23, there seems to be a DrawableWrapperCompat
though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was the compat DrawableWrapper
:
material-components-android/lib/java/com/google/android/material/drawable/ScaledDrawableWrapper.java
Line 5 in 58f5439
import androidx.appcompat.graphics.drawable.DrawableWrapper; |
Anyway, I've rebased the PR and updated this class.
58f5439
to
e898844
Compare
This PR:
thumbIconWidth
andthumbIconHeight
withthumbIconSize
(as in other components such asMaterialButton
,FloatingActionButton
,Chip
,Card
, and so on).