【问题标题】:Scroll screen until list reaches top滚动屏幕直到列表到达顶部
【发布时间】:2021-09-09 20:24:04
【问题描述】:

那么我如何滚动屏幕,里面有一个惰性列? 我只是尝试测试它在包含惰性列的父框中设置一个verticalScroll(记住..)和许多其他可组合但我收到了这个错误:

java.lang.IllegalStateException: Nesting scrollable in the same direction layouts like LazyColumn and Column(Modifier.verticalScroll()) is not allowed.

If you want to add a header before the list of items please take a look on LazyColumn component which has a DSL api which allows to first add a header via item() function and then the list of items via items().

所以我想将此屏幕滚动到 2 个框消失并且惰性列保持在顶部的位置。如果有项目,则在滚动时保持在顶部。 (但永远不会消失在屏幕上。就像它在使用它的高度一样)

【问题讨论】:

    标签: android android-jetpack-compose


    【解决方案1】:

    您也可以将您的盒子放入LazyColumn,如下所示:

    LazyColumn {
        item {
            Box {
                Text("Box 1")
            }
        }
        item {
            Box {
                Text("Box 2")
            }
        }
        items(dataItems) { dataItem ->
            // ..
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2010-11-16
      • 1970-01-01
      • 2021-12-31
      • 2016-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多