HarmonyOS 自定义弹窗CustomDialog会导致键盘收起

CustomDialog文档中描述“由于弹窗存在完全避让输入法行为,即在软键盘弹出时,会自动向上抬起软键盘高度,因此如果弹窗高度过大时,可能会导致部分区域不可见。弹窗避让软键盘时,与软键盘之间存在16vp的安全间距。”

@Component  
export struct PageA {  
  @Consume('pageInfos') pageInfos: NavPathStack;  
  @State message: string = 'Hello World';  
  controller: TextInputController = new TextInputController()  
  @State offsetY: number = 50  
  dialogControllerProgress: CustomDialogController = new CustomDialogController({  
    builder: FZSearchSelfStockOperationView(),  
       isModal: false, //不展示蒙层  
    autoCancel: false,  
    customStyle: true,  
    alignment: DialogAlignment.Center,  
    height: 100,  
    offset: {dx: 0, dy: this.offsetY}  
  })  
  build() {  
    NavDestination() {  
      Column() {  
        TextInput({ text: this.message, placeholder: 'input your word...', controller: this.controller })  
          .id('AAAA')  
          .type(InputType.Normal)  
  
        Button(" toast ")  
          .width(200)  
          .height(88)  
          .fontSize(16)  
          .onClick(() => {  
            this.dialogControllerProgress.open()  
          })  
      }.width('100%').height('100%').backgroundColor(Color.Gray)  
    }.title('PageA').hideTitleBar(true)  
  }  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.

1、通过inspector自定义弹窗height属性不生效,无法对上述描述进行验证。

2、弹窗弹出后,TextInput变为非编辑态、键盘消失,并且点击TextInput不能重新调起键盘。能否实现弹窗跟随键盘的收起弹窗而移动。

HarmonyOS
2024-10-16 11:39:02
971浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
superinsect

可以参考如下demo:

@Entry  
@Component  
struct Main4 {  
  @State isShow: boolean = false  
  @Builder  
  myBuilder() {  
    Column() {  
      Button("关闭半模态").onClick(()=>{  
        this.isShow = false  
      })  
      TextInput()  
    }  
    .expandSafeArea([SafeAreaType.SYSTEM,SafeAreaType.KEYBOARD], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])  
    .borderRadius(10)  
    .width("100%")  
  }  
  build() {  
    Column() {  
      Button('click me 打开半模态')  
        .onClick(() => {  
          this.isShow = !this.isShow  
        })  
    }  
    .expandSafeArea([SafeAreaType.SYSTEM,SafeAreaType.KEYBOARD], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])  
    .bindSheet($$this.isShow, this.myBuilder(), { height: 400})  
    .justifyContent(FlexAlign.End)  
    .width('100%')  
    .height('100%')  
  }  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
分享
微博
QQ
微信
回复
2024-10-16 16:57:37


相关问题
HarmonyOS 自定义弹窗CustomDialog
801浏览 • 1回复 待解决
HarmonyOS 自定义弹窗CustomDialog问题
1389浏览 • 1回复 待解决
HarmonyOS 自定义弹窗CustomDialog 问题
836浏览 • 1回复 待解决
HarmonyOS 自定义弹窗 (CustomDialog)问题
1330浏览 • 1回复 待解决
HarmonyOS 自定义弹窗CustomDialog调用问题
1173浏览 • 1回复 待解决
CustomDialog自定义动画
1389浏览 • 1回复 待解决
HarmonyOS 自定义键盘
1042浏览 • 1回复 待解决
自定义弹窗自定义转场动画
1997浏览 • 1回复 待解决