Strange shadow behavior during `alpha` animation

ぐ巨炮叔叔 提交于 2019-12-12 10:43:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!