鸿蒙ArkTs如何实现Scroll容器组件中子组件吸顶效果

```

@Entry

@Component

struct Index {

    @Builder

    CustomHeader() {

        Text('2222222')

            .height(30)

            .backgroundColor(Color.Gray)

            .width('100%')

    }

    build() {

        List({

            space: 10

        }) {

            ListItem() {

                Text('111111')

                    .height(30)

                    .backgroundColor(Color.Gray)

                    .width('100%')

            }

            ListItemGroup({

                header: this.CustomHeader,

                space: 10

            }) {

                ForEach(Array.from({

                    length: 20

                }), (item: void, index: number) => {

                    ListItem() {

                        Text(index + '')

                            .height(30)

                            .backgroundColor('#f00')

                            .width('100%')

                    }

                })

            }

        }

        .width('100%')

        .height(200)

        .sticky(StickyStyle.Header)

    }

}

export default Index

```

华为开发者论坛

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容