想要页面高度不随键盘变化,需要给对应的组件设置expandSafeArea。demo:@Entry @Component struct keywordExpandSafe { @State message: string = 'Hello World'; @State arr:number[] = [] aboutToAppear(): void { for (let index = 0; index < 14; index++) { this.arr.push(index) } } build() { Row() { Column() { ForEach((this.arr), (temp: number) => { TextInput().backgroundColor(Color.Pink) }) TextInput() Text(this.message) .fontSize(50) .fontWeight(FontWeight.Bold) .onClick(() => { }) } .width('100%') } .height('100%') .expandSafeArea([SafeAreaType.KEYBOARD]) } }
想要页面高度不随键盘变化,需要给对应的组件设置expandSafeArea。
demo: