提交 ae0c20c8 编写于 作者: S sunjiakun

list scroll snap

Signed-off-by: Nsunjiakun <sunjiakun3@huawei.com>
上级 e2f9745d
......@@ -323,3 +323,50 @@ struct ListExample{
```
![list](figures/list3.gif)
### 示例4
```ts
// xxx.ets
@Entry
@Component
struct ListExample {
private arr: number[] = Array.apply(this, {length: 20}).map((item, i) => i)
private scrollerForList: Scroller = new Scroller()
build() {
Column() {
Row() {
List({ space: 20, initialIndex: 0, scroller: this.scrollerForList }) {
ForEach(this.arr, (item) => {
ListItem() {
Text('' + item)
.width('100%').height(100).fontSize(16)
.textAlign(TextAlign.Center)
}
.borderRadius(10).backgroundColor(0xFFFFFF)
.width('60%')
.height('80%')
}, item => item)
}
.chainAnimation(true)
.edgeEffect(EdgeEffect.Spring)
.listDirection(Axis.Horizontal)
.height('100%')
.width('100%')
.scrollSnapAlign(ScrollSnapAlign.CENTER)
.borderRadius(10)
.backgroundColor(0xDCDCDC)
.listDirection(Axis.Horizontal)
.width('100%')
}
.width('100%')
.height('100%')
.backgroundColor(0xDCDCDC)
.padding({ top: 10})
}
}
}
```
![list](figures/list4.gif)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册