首页 > 解决方案 > 如何在用xml编写的标准底页对话框中使用jetpack compose的lazyColumn?

问题描述

我想通过以下代码在用xml编写的底部工作表对话框中添加lazyColumn:


    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/coordin"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <FrameLayout
            android:id="@+id/bottomSheet"
            style="@style/FeedbackBottomSheetDialog"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
         app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

            <androidx.core.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fillViewport="true">

                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <androidx.compose.ui.platform.ComposeView
                        android:id="@+id/search_engine_compose_view"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />
                </FrameLayout>

            </androidx.core.widget.NestedScrollView>

        </FrameLayout>

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

在撰写视图中,lazyColumn 将被放置。问题是我不能将lazyColumn 与 NestedScrollView 一起使用,并出现以下错误和应用程序崩溃:

不允许在相同方向的布局中嵌套可滚动,例如 LazyColumn 和 Column(Modifier.verticalScroll())。 有没有人有任何想法如何解决这个问题。这是我的lazyColumn可组合

@Composable
fun MovieList(
    movieName: List<String>
) {
    LazyColumn {
        items(movieName.size)
        {
            Text(movieName)
        }
    }
}

标签: androidandroid-jetpack-compose

解决方案


在我的情况下,我有

<FrameLayout
    isNestedScrollingEnabled = "true">
<ComposeView/>
</FrameLayout>

一切似乎都很好


推荐阅读