android - Scrolling Column inside LazyColumn - Stack Overflow

I have a Column inside the LazyColumn with some elements like this:LazyColumn {item {...}item {...}ite

I have a Column inside the LazyColumn with some elements like this:

LazyColumn {
    item {
        ...
    }
    item {
        ...
    }
    item {
        ...
    }
    item {
        HorizontalPager() {
           if(page == 1) {
              Button(onClick = {})
              Column {
                 itemsList.forEach {
                    SomeComponent(it)
                 }
               }
           }
           ....
        }
       
    }
}

What would be the best way to scroll to the specific SomeComponent item inside the column? I was trying with lazyListState.animateScrollToItem but the list has only 4 elements so I can scroll only to the beginning of the Column.

I have a Column inside the LazyColumn with some elements like this:

LazyColumn {
    item {
        ...
    }
    item {
        ...
    }
    item {
        ...
    }
    item {
        HorizontalPager() {
           if(page == 1) {
              Button(onClick = {})
              Column {
                 itemsList.forEach {
                    SomeComponent(it)
                 }
               }
           }
           ....
        }
       
    }
}

What would be the best way to scroll to the specific SomeComponent item inside the column? I was trying with lazyListState.animateScrollToItem but the list has only 4 elements so I can scroll only to the beginning of the Column.

Share Improve this question edited 4 hours ago falsetto asked 21 hours ago falsettofalsetto 7892 gold badges11 silver badges35 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can try to add the SomeComponent Composables to the LazyColumn directly:

LazyColumn {
    item {
        //...
    }
    item {
        //...
    }
    item {
        //...
    }
    item {
        Button(onClick = {})
    }
    items(itemsList) {
        SomeComponent(it)
    }
}

Then, you can use

lazyListState.animateScrollToItem(4 + itemIndexInNestedList)

to scroll to a certain SomeComponent.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743767652a4503791.html

相关推荐

  • android - Scrolling Column inside LazyColumn - Stack Overflow

    I have a Column inside the LazyColumn with some elements like this:LazyColumn {item {...}item {...}ite

    7天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信