HarmonyOS 鸿蒙Next中软键盘弹起来时,Scroll为什么自动扩展了安全区域
HarmonyOS 鸿蒙Next中软键盘弹起来时,Scroll为什么自动扩展了安全区域
Scroll 容器 为什么 自动扩展到了菜单栏 ??
更多关于HarmonyOS 鸿蒙Next中软键盘弹起来时,Scroll为什么自动扩展了安全区域的实战教程也可以访问 https://www.itying.com/category-93-b0.html
3 回复
设置虚拟键盘避让模式 setKeyboardAvoidMode
,代码参考
import { KeyboardAvoidMode } from '@kit.ArkUI';
@Component
struct Index3 {
private list: string[] = []
private scroller = new Scroller()
aboutToAppear(): void {
for (let i = 0; i < 200; i++) {
this.list.push(`选项${i}`)
}
this.getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE)
}
build() {
Column () {
Text('我是固定标题')
.fontColor(Color.White)
.backgroundColor(Color.Red)
List({ scroller: this.scroller, initialIndex: this.list.length - 1 }) {
ForEach(this.list, (item: string) => {
ListItem () {
Text(item).padding(10)
}
})
}
.layoutWeight(1)
TextInput()
}
.height('100%')
.width('100%')
}
}
更多关于HarmonyOS 鸿蒙Next中软键盘弹起来时,Scroll为什么自动扩展了安全区域的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在HarmonyOS鸿蒙Next中,软键盘弹出时,Scroll会自动扩展安全区域,这是为了确保输入内容不被键盘遮挡,提升用户体验。系统默认会调整布局,使输入框保持在可视区域,用户无需手动滑动即可看到输入内容。这一行为符合鸿蒙系统的自适应布局设计,确保在不同设备和场景下都能提供一致的用户体验。开发者可以通过设置adjustResize
或adjustPan
来调整这一行为。