Android 使用Crossfade的MotionLayout-altSrc显示在src的顶部(原始图像不会褪色)
我使用ImageFilterView与MotionScene配合,在用户滑动时在图像之间切换(我还将图像向上移动) 新图像确实出现,但旧图像仍保留。我可以看到原始图像上方的altSrc图像 我做错什么了吗我对旧图像将淡出的预期是否不正确? 以下是相关代码: layout.xml:Android 使用Crossfade的MotionLayout-altSrc显示在src的顶部(原始图像不会褪色),android,android-appcompat,android-constraintlayout,android-motionlayout,Android,Android Appcompat,Android Constraintlayout,Android Motionlayout,我使用ImageFilterView与MotionScene配合,在用户滑动时在图像之间切换(我还将图像向上移动) 新图像确实出现,但旧图像仍保留。我可以看到原始图像上方的altSrc图像 我做错什么了吗我对旧图像将淡出的预期是否不正确? 以下是相关代码: layout.xml: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.motion.widget.MotionLayout xmlns:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout 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:id="@+id/motionlayout_demo"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/the_scene_alt"
app:showPaths="true"
tools:context="com.designdemo.uaha.ui.MotionLayoutActivity">
...
<androidx.constraintlayout.utils.widget.ImageFilterView
android:id="@+id/nerd_text_img"
android:src="@drawable/ic_nerderytxt_old"
app:altSrc="@drawable/ic_nerderytxt_new"
android:layout_width="450dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.43"/>
...
</androidx.constraintlayout.motion.widget.MotionLayout>
...
...
场景\u alt.xml
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@+id/start"
motion:duration="1000">
<OnSwipe
motion:dragDirection="dragUp"
motion:touchAnchorId="@id/text_the"
motion:touchAnchorSide="right" />
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/nerd_text_img"
android:layout_width="450dp"
android:layout_height="wrap_content"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintVertical_bias="0.43" >
<CustomAttribute
motion:attributeName="Crossfade"
motion:customFloatValue="0" />
</Constraint>
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/nerd_text_img"
android:layout_width="450dp"
android:layout_height="wrap_content"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintVertical_bias="0.33" >
<CustomAttribute
motion:attributeName="Crossfade"
motion:customFloatValue="1" />
</Constraint>
</ConstraintSet>
使用标志:
app:overlay=“false”据我所知,这可能会像预期的那样工作。交叉淡入淡出将图像置于顶部,而不改变基础层。希望我能得到官方的确认。嘘!希望我们能改变这一点,现在我只是把背景放到图片中,不是很好,但它会为我的目的工作。是的,他们添加了一个修复!lib的作者添加了一个答案!看起来这个答案是最近(由CL的作者)添加的,所以我假设这是对库的一个新添加。在考虑ImageFilterView最初存在的原因时,这并不明显。我认为最常见的用例是交叉淡入淡出,这应该是默认行为。也许我需要创建一个到谷歌的票证来改变行为,或者在Android Studio 4.0运动编辑器中添加对此的支持。