question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MaterialCardView] Unwanted border around cardview when having different border radii

See original GitHub issue

Description: When changing the Shape of a Material Card to include only 2 rounded borders, there is an additional ~2dp border around the card that clips over content.

See screenshot: https://i.imgur.com/kES7C2W.png

Expected behavior: No border would be there. If all borders are rounded/not rounded, this does not happen

Source code:

<style name="ShapeAppearanceOverlay.MyApp.MaterialCardView" parent=""> <item name="cornerFamily">rounded</item> <item name="cornerSizeTopLeft">8dp</item> <item name="cornerSizeTopRight">8dp</item> <item name="cornerSizeBottomLeft">0dp</item> <item name="cornerSizeBottomRight">0dp</item> </style>

Android API version: 29

Material Library version: 1.2.0-alpha03

Device: Nexus5, Google Pixel, Samsung S7

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
trifagabrielcommented, Sep 29, 2021

Setting android:outlineProvider=“none” fixed the issue for me

3reactions
pekingmecommented, Jan 17, 2020

Hi @kelmer44, thanks for providing the info. After trying your layout and style, I don’t think I fully understand your issue. But here are something I found.

  • Apply theShapeAppearanceOverlay.MyApp.MaterialCardView to app:shapeAppearance instead of style to make it take effect.
  • The extra padding inside the card background is to prevent overlapping the content with corner. If this is not desired, you can set app:cardPreventCornerOverlap to false in MaterialCardView to disable it.
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove MaterialCardView borders - Stack Overflow
CardView (the old CardView included in support library). You can change the border using the app:strokeWidth attribute. The default value is 0.
Read more >
CardView | Android Developers
CardView uses elevation property on Lollipop for shadows and falls back to a custom emulated shadow ... Returns the corner radius of the...
Read more >
How To Make Child Imageview Take The Shape Appearance ...
To get the rounded corner, bitmap height and width should be same - Suchith Another easy way is to use a CardView with...
Read more >
How to give border color to CardView in android
Android CardView widget allows us to control the background color, shadow, corner radius, elevation etc. For using the custom attributes in XML, we...
Read more >
Customize Card Border in Flutter | Ultimate Guide of 2022
We'll also see different ways to add border. ... To add border radius or create a rounded border around the card you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found