该间隙是dialog的规格问题,软键盘拉起后,弹框和软键盘距离16vp导致的,可在弹窗位置设置:.offset({ x: 0, y: 16 }) 即可,参考代码如下所示:import { BusinessError } from '@kit.BasicServicesKit'; import { ComponentContent } from '@kit.ArkUI'; class Params { text: string = "" constructor(text: string) { this.text = text; } } @Builder function buildText(params: Params) { Column() { TextInput({ placeholder: 'input your word...' }) .placeholderColor(Color.Grey) .placeholderFont({ size: 14, weight: 400 }) .caretColor(Color.Blue) .width('95%') .height(40) .margin(20) .fontSize(14) .fontColor(Color.Black) } .backgroundColor('#FFF0F0F0') .borderRadius(12) .height(350) .width('100%') .offset({ x: 0, y: 16 }) //弹窗位置,y等于16的时候刚刚好 } @Entry @Component struct Index { @State message: string = "hello" build() { Row() { Column() { Button("click me") .onClick(() => { let uiContext = this.getUIContext(); let promptAction = uiContext.getPromptAction(); let contentNode = new ComponentContent(uiContext, wrapBuilder(buildText), new Params(this.message)); try { promptAction.openCustomDialog(contentNode, { alignment: DialogAlignment.Bottom, offset: { dx: 0, dy: 0 } }); } catch (error) { let message = (error as BusinessError).message; let code = (error as BusinessError).code; console.error(`OpenCustomDialog args error code is ${code}, message is ${message}`); } ; }) } .width('100%') .height('100%') } .height('100%') } }
该间隙是dialog的规格问题,软键盘拉起后,弹框和软键盘距离16vp导致的,可在弹窗位置设置:.offset({ x: 0, y: 16 }) 即可,参考代码如下所示: