Scroll(this.scroller) {
Column() {
ForEach(this.arr, (item: number) => {
Text("ListItem" + item)
.width("100%")
.height(150)
.borderRadius(15)
.fontSize(16)
.textAlign(TextAlign.Center)
.backgroundColor(Color.White)
}, (item: string) => item)
}
.width('100%')
}
.width("100%")
.height(200) 修改滑动区域高度值,也设置为百分比占比,在平板上时可以同比放大。
@Entry
@Component
struct ScrollPage3432 {
private arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
scroller: Scroller = new Scroller();
build() {
Flex() {
Column() {
Text("Scroll Area")
.width("100%")
.height('20%')
.backgroundColor('#D1D1D6')
.fontSize(16)
.textAlign(TextAlign.Center);
Scroll(this.scroller) {
Column() {
ForEach(this.arr, (item: number) => {
Text("ListItem" + item)
.width("100%")
.height(150)
.borderRadius(15)
.fontSize(16)
.textAlign(TextAlign.Center)
.backgroundColor(Color.White);
}, (item: string) => item);
}
.width('100%');
}
.width("100%")
// 高度设置为百分比
.height('60%');
Text("Scroll Area")
.width("100%")
.height('20%')
.backgroundColor('#D1D1D6')
.fontSize(16)
.textAlign(TextAlign.Center);
};
}
.width("100%").height("100%");
}
}