android - MotionLayout keyTrigger 不能正常工作?
问题描述
我有 MotionLayout xml 文件
<androidx.constraintlayout.motion.widget.MotionLayout
android:id="@+id/motionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#1e376b"
app:layoutDescription="@xml/motion_layout_header_scene">
<ImageView
android:id="@+id/background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:scaleType="centerCrop"
app:srcCompat="@drawable/icon_schiller"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.motion.widget.MotionLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollable"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text=“@string/long_text />
</androidx.core.widget.NestedScrollView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="@android:drawable/ic_input_add" />
这是我的场景文件
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@+id/start"
motion:duration="250"
motion:motionInterpolator="linear">
<OnSwipe
motion:dragDirection="dragUp"
motion:touchAnchorId="@+id/motionLayout"
motion:touchAnchorSide="bottom" />
<KeyFrameSet>
<KeyTrigger
motion:framePosition="20"
motion:motionTarget="@id/fab"
motion:onPositiveCross="hide" />
<KeyTrigger
motion:framePosition="40"
motion:motionTarget="@id/fab"
motion:onNegativeCross="show" />
</KeyFrameSet>
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/motionLayout"
android:layout_width="match_parent"
android:layout_height="200dp"
motion:layout_constraintTop_toTopOf="parent" />
<Constraint
android:id="@id/scrollable"
android:layout_width="match_parent"
android:layout_height="0dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/motionLayout" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/motionLayout"
android:layout_width="match_parent"
android:layout_height="56dp"
motion:layout_constraintTop_toTopOf="parent"
motion:progress="1" />
<Constraint
android:id="@id/scrollable"
android:layout_width="match_parent"
android:layout_height="0dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/motionLayout" />
</ConstraintSet>
但是您可以在视频中看到 fab 存在问题,向上滚动时它会消失,然后当我向下滚动时它不会再次出现。 https://drive.google.com/file/d/1-V5EAdKd0EDfYOKE0ElgfEOSOoUUZrCK/view?usp=sharing
解决方案
谷歌问题跟踪器中目前存在一个错误:https ://issuetracker.google.com/issues/135938944 。
推荐阅读
- python-3.x - 通过 PSexec 和 python 脚本捕获在远程机器上运行的 wmic 查询的输出
- javascript - 鼠标移出后显示子菜单
- exceldatareader - ExcelDataReader 3.4 - System.IO.FileLoadException
- java - 如果一个java pojo被声明为一个对象,如何根据运行时类型控制jackson序列化?
- vb.net - 如何找到二进制 16 位数字的每个组合
- c# - 如何获取 Windows 客户端用户 ASPX C#
- python - 从 dict1 更新 dict2 的值,但在 dict2 的特定位置
- java - 使用 S/4HANA Cloud SDK >= 2.0.0 执行 OData 查询时的 DestinationAccessException
- dialog - wxPython;如果取消一个对话框,则关闭所有对话框
- c# - MONO - C# UdpClient 未接收来自本地广播 ip 的消息