Search code examples
androidandroid-layoutandroid-cardviewandroid-9.0-pie

CardCornerRadius in cardview looking weird in android Pie


My CardView was being shown as expected till android O like this,

But in android P it looks like this, (Transparent white rectangle inside)

This is the style used in all CardView of the app.

 <style name="translucentCard" parent="CardView">
        <item name="cardCornerRadius">20dp</item>
        <item name="cardBackgroundColor">#26ffffff</item>
 </style>

If I use non-transparent cardBackgroundColor then the inner rectangle disappears but it's not the solution. I need to use semi-transparent color as used before. Can anyone help me to overcome this please ? Please note, It's only happening in Android Pie.


Solution

  • backward compatible elevation on the latest release

    app:cardElevation="0dp"
    

    OR

    <item name="cardElevation">0dp</item>