You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 01:33:27