问题
Have recycler with CardView
items. When screen open - I start alpha animation on recycler :
recyclerView.animate().alpha(1f).setStartDelay(300).start()
Recycler item:
<android.support.v7.widget.CardView
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="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="6dp"
app:cardCornerRadius="10dp"
app:cardElevation="4dp">
...
</android.support.v7.widget.CardView>
Problem that while this animation running the shadow of CardView
directed to the up but when animation ends shadow change direction to the bottom (as normal)
Problem was found only on Android 9.
P.S. sorry for my english)
回答1:
I have found a partial fix,
If you add android:layerType="hardware" to the parent view the shadow no longer flips direction.
The down side is the shadow permanently points in the wrong direction.
来源:https://stackoverflow.com/questions/54646927/strange-shadow-behavior-during-alpha-animation