Elevated CardView items in a Recyclerview get progressively more shadow

Viewed 291

I'm wondering why each card in my recyclerview has more shadow than the card before. Is this normal behaviour? if not, what causes this and how can i avoid it?

I can't find any information on this anywhere outside of an old stackoverflow post (Elevated RecyclerView items get progressively deformed (elevation changes))

The list item layout

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="280dp"
android:layout_height="180dp"
app:cardCornerRadius="20dp"
app:cardUseCompatPadding="true"
app:cardElevation="6dp">

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</androidx.constraintlayout.widget.ConstraintLayout>

</com.google.android.material.card.MaterialCardView>

enter image description here

2 Answers

there are two light sources in Android - "ambient" (general, "flat") and "key" (wirtually located at some point in space). HERE you will find some doc/description. First one gives you equal shadow around card. Second one gives "more" shadow at the opposite edge that "key" light is placed

"key" light is placed on top of the screen. Lets imagine that status bar is "key" light:

  • card on top of list is very near status bar, almost under it, so it have small "bottom" shadow, as a man have smaller shadow standing in the field at the midday
  • card on the bottom of screen is far from status bar, so its shadow is longer, just like shadows on sunset

some more info in this SO

Related