android - MotionLayout 使用 Crossfade - altSrc 出现在 src 之上(原始图像不会消失)
问题描述
我正在使用 ImageFilterView,与 MotionScene 配合,在用户滑动时在图像之间切换(我也在向上移动图像)。
新图像确实出现了,但旧图像仍然存在。我可以在原始图像之上看到altSrc图像。
难道我做错了什么? 我的预期是否不正确,旧图像会淡出?
以下是相关代码:
布局.xml:
<?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>
the_scene_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"
推荐阅读
- javascript - 尽管使用了唯一的字符串,为什么我的代码表现得就像我在字典中有重复的键?Javascript / Appscript
- c++ - 如何使用模板成员函数作为另一个模板成员函数的参数?
- c# - 获取网络接口的全名C#
- reactjs - Formik 对象不渲染
- ios - 每个应用程序可以有多个应用程序剪辑吗?
- css - CSS 淡出页面之间的过渡
- database - Create 2 documents when posting to CouchDB
- java - Project Reactor 条件流的最佳实践
- react-native - React native - 单页导航,滚动到特定部分
- python - 根据现有变量在数据框中创建新变量