4
votes

enter image description here

I have tried using https://github.com/captain-miao/OptionRoundCardview this repo but it didn't help the cause as it was giving edged corners.

1
The above links answers only rounded corners and non rounded corners but my problem is to get the different radiuses for different corners.Karnaker Reddy Gaddampally
@Nilesh Rathod Please help to expalin why its a duplicate question.Karnaker Reddy Gaddampally
@NileshRathod the above link can have the shape but need the elevation and shadow exactly as per the outline.Karnaker Reddy Gaddampally
You can use the standard MaterialCardView with a simple style. Just check the answer.Gabriele Mariotti

1 Answers

3
votes

You can use the standard MaterialCard included in the official Material Components library.

Use in your layout:

<com.google.android.material.card.MaterialCardView
        style="@style/MyCardView"
        ...>

In your style use the new shapeAppearanceOverlay attribute to customize the shape (It requires the version 1.1.0.)

  <style name="MyCardView" parent="@style/Widget.MaterialComponents.CardView">
    <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay_only_on_top</item>
  </style>

Something like:

  <style name="ShapeAppearanceOverlay.MaterialCardView.Cut" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSizeTopRight">4dp</item>
    <item name="cornerSizeTopLeft">4dp</item>
    <item name="cornerSizeBottomRight">16dp</item>
    <item name="cornerSizeBottomLeft">4dp</item>
  </style>

enter image description here