-
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
[MaterialCardView] Stroke not correctly overlapping corners #881
Comments
Hey Thomas! Thanks for reporting this. Just for clarification, by saying "correctly overlap all corners", do you mean that the expected appearance of the round corner shown in the picture should not have that thin line zig-zaging on the outer edge of the stroke? |
Hi @pekingme. Thanks for your quick answer. This is maybe similar to #757 I tried to figure out the reason, and my guess is that it's an issue inside the MaterialShapeDrawable class, since it contains logic to calculate the stroke paths. |
@G00fY2 Hi this is due to Anti aliasing. The background and the stroke are drawn on the same pixels but depending on the color of the stroke the transparent pixels added by the AA can cause the bleed through. That's why you won't see it if you invert the colors here. We fixed this in the past by adding another layout inside the card and drawing the stroke outside that layout. We decided this wasn't worth it because it caused many problems. 0f8fa7e#diff-54cfea65201fdba3911acbc81d757c37 We have been talking about moving the stroke to the background of the card instead of the foreground so I think that's the only way we will get this fixed, but it's a complicated change to make. |
I see, thats makes sense. Maybe you can come up with a solution. Right now using strokes with MaterialCardView can really look bad depending on the color combination and radius used. Adding margins to inner views as a workaround looks somehow okay in our case. |
Yes sadly this looks really bad, but only on the left side. Any news on this? |
Adding margins to inner views is not a solution for me, as i need to overlay a shadow gradient. Any progress on a proper solution for this? |
@G00fY2 @KlassenKonstantin @nicusorflorin |
Description: When using MaterialCardView with a StrokeColor and StrokeWidth set, the rendered stroke does not fully overlap rounded corners.
Expected behavior: The stroke should correctly overlap all corners
Source code:
layout:
styles:
Android API version: Reproducible with API 29 to 21.
Material Library version: Reproducible with 1.1.0-rc1 and 1.2.0-alpha03
Device: Emulator and real devices (Pixel 1 e.g.)
The text was updated successfully, but these errors were encountered: