HarmonyOS 如何让@CustomDialog自定义弹窗不被软键盘顶起

HarmonyOS
2024-12-26 15:11:48
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Excelsior_abit

可以使用半模态弹窗,案例如下:

@Entry
@Component
struct SheetTransition {
  @State isShow:boolean = false
  @State sheetHeight:number = 300;
  private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12]
  @Builder myBuilder() {
    Column() {
      Button("content1")
        .margin(10)
        .fontSize(20)
      TextInput({placeholder: '请输入内容'})
      Button("content2")
        .margin(10)
        .fontSize(20)
    }
    .width('100%')
  }
  build() {
    Column() {
      Button("transition modal 1")
        .onClick(() => {
          this.isShow = true
        })
        .fontSize(20)
        .margin(10)
        .bindSheet($$this.isShow, this.myBuilder(), {
          height: this.sheetHeight,
          onAppear: () => {console.log("BindSheet onAppear.")},
          onDisappear: () => {console.log("BindSheet onDisappear.")}
        })
      List(){
        ForEach(this.arr,(item:number,)=>{
          ListItem(){Row(){Text('文本')}.justifyContent(FlexAlign.Center).width('100%').backgroundColor(0xFFFFFF).height(100)}
        })
      }.divider({strokeWidth:2,color:'#F1F3F5'}).height('90%')
    }
    .justifyContent(FlexAlign.Start)
    .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.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
分享
微博
QQ
微信
回复
2024-12-26 17:14:21
相关问题
HarmonyOS 半模态会被软键盘顶起
695浏览 • 1回复 待解决
HarmonyOS 弹窗不避让软键盘
1350浏览 • 1回复 待解决
CustomDialog软键盘的问题
1162浏览 • 1回复 待解决
HarmonyOS 如何实现弹窗不规避软键盘
997浏览 • 1回复 待解决
HarmonyOS 弹窗布局被软键盘压缩
587浏览 • 1回复 待解决
HarmonyOS 自定义弹窗CustomDialog
786浏览 • 1回复 待解决
HarmonyOS 自定义弹窗CustomDialog问题
1370浏览 • 1回复 待解决
HarmonyOS 自定义弹窗CustomDialog 问题
803浏览 • 1回复 待解决
HarmonyOS 自定义键盘不能顶起输入框
1250浏览 • 1回复 待解决
如何实现弹窗软键盘的避让
2320浏览 • 1回复 待解决
HarmonyOS 自定义弹窗 (CustomDialog)问题
1303浏览 • 1回复 待解决
HarmonyOS 自定义弹窗CustomDialog调用问题
1131浏览 • 1回复 待解决