问题描述
我在容器中替换了两个片段。我的问题是在我用于事务的自定义动画期间的高程阴影。我将持续时间设置为两秒以正确查看它,并且在事务期间似乎只有来自环境光的阴影可见,并且仅在动画结束后才显示关键光阴影(参见 https://material.io/design/environment/light-shadows.html#light)。有大佬知道怎么处理吗?
这是一些源代码和视频
卡片视图布局
<androidx.cardview.widget.CardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_8dp"
app:cardElevation="@dimen/elevation_4dp"
app:cardCornerRadius="@dimen/corner_16dp">
交易代码
supportFragmentManager
.beginTransaction()
.setCustomAnimations(
R.anim.fade_in,R.anim.fade_out,R.anim.fade_in,R.anim.fade_out
).replace(R.id.fragment_container,questionsFragment,"questions")
.commit()
动画xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000">
<alpha
android:fromAlpha="0"
android:toAlpha="1"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
</set>
这是该问题的示例视频 https://www.youtube.com/watch?v=dUe1GT4dAFQ
提前致谢。
解决方法
尝试将动画持续时间从 2 秒减少到 500 毫秒或 1000 毫秒。