Compose与Motion Layout交互时滚动失效,如何恢复原有滚动行为?
问题
原Fragment布局结构如下:
Header Image ==================================== Tab 1. Tab2. Tab3. ==================================== Frag A. Frag B. Frag C.
该Fragment配置了Motion Scene,向上滚动时头部图片会过渡为常规Toolbar。将Tab3对应的Fragment迁移到Compose后(通过XML中的ComposeView标签,在Fragment中调用setContent实现),功能正常,但在该Fragment上向上滚动时,Motion Scene不再生效,仅内容内部滚动(类似NestedScrollView的行为)。请问是否仍能触发Motion Layout,使Fragment保持原有滚动行为?
更新
已采纳解决方案,同时修正了XML布局,移除了SwipeRefreshLayout(该功能将在Compose中实现)。原布局代码如下:
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout 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/swipeToRefreshLayout" android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.compose.ui.platform.ComposeView android:id="@+id/compose_view" android:layout_width="match_parent" android:layout_height="match_parent" /> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
内容的提问来源于stack exchange,提问作者Beto
相关产品推荐
相关产品推荐

