Android MotionLayout:点击并触摸不在视图中工作,在运动场景中转换(类似Youtube播放器的UI)
我有一个类似Youtube视频播放器的视图,在这里我有一个列表,点击后在下一个屏幕上播放视频 我已将Motionscene添加到视频视图中,因此在向下拖动时,视频视图会变小。但在执行此操作时,onClick或onTouch事件不适用于播放/暂停控件 在youtube上,我们可以看到两者都工作得很好。所以我想知道我哪里做错了 动态场景:Android MotionLayout:点击并触摸不在视图中工作,在运动场景中转换(类似Youtube播放器的UI),android,android-layout,android-constraintlayout,android-motionlayout,Android,Android Layout,Android Constraintlayout,Android Motionlayout,我有一个类似Youtube视频播放器的视图,在这里我有一个列表,点击后在下一个屏幕上播放视频 我已将Motionscene添加到视频视图中,因此在向下拖动时,视频视图会变小。但在执行此操作时,onClick或onTouch事件不适用于播放/暂停控件 在youtube上,我们可以看到两者都工作得很好。所以我想知道我哪里做错了 动态场景: <MotionScene xmlns:android="http://schemas.android.com/apk/res/android" xm
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@id/collapsed"
motion:constraintSetStart="@id/expanded"
motion:duration="100">
<OnSwipe
motion:dragDirection="dragDown"
motion:maxAcceleration="200"
motion:touchAnchorId="@+id/player"
motion:touchAnchorSide="bottom" />
</Transition>
<ConstraintSet android:id="@+id/expanded">
<Constraint
android:id="@id/player"
android:layout_height="200dp"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
<Constraint
android:id="@id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="visible"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintTop_toBottomOf="@id/player" />
</ConstraintSet>
<ConstraintSet android:id="@+id/collapsed">
<Constraint
android:id="@id/player"
android:layout_height="85dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent" />
<Constraint
android:id="@id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="gone"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintTop_toBottomOf="@id/player" />
</ConstraintSet>
</MotionScene>
依赖项:
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
我通过在NestedScrollView中包装所需的元素解决了这个问题
app:layoutDescription="@transition/profile_animations_user_other"
app:showPaths="false">
<androidx.core.widget.NestedScrollView
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/divider">
<LinearLayout ..../>
</androidx.core.widget.NestedScrollView>
app:layoutDescription=“@transition/profile\u animations\u user\u other”
应用程序:showPaths=“false”>
配置文件\u动画\u用户\u其他
<Transition
app:constraintSetEnd="@id/end"
app:constraintSetStart="@id/start"
app:duration="1000">
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/view_pager"
app:touchAnchorSide="top" />
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/toolbar"
app:touchAnchorSide="top" />
</Transition>
我也面临同样的问题。你找到解决办法了吗?
app:layoutDescription="@transition/profile_animations_user_other"
app:showPaths="false">
<androidx.core.widget.NestedScrollView
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/divider">
<LinearLayout ..../>
</androidx.core.widget.NestedScrollView>
<Transition
app:constraintSetEnd="@id/end"
app:constraintSetStart="@id/start"
app:duration="1000">
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/view_pager"
app:touchAnchorSide="top" />
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/toolbar"
app:touchAnchorSide="top" />
</Transition>