HarmonyOS 输入法弹出后遮挡界面按钮怎么处理?

登录页弹出输入面板后,遮挡了登录按钮

HarmonyOS
2024-12-20 16:56:16
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

参考以下demo:

import window from '@ohos.window';

@Entry
@Component
struct Index {
  @State screenHeight: number = 0;

  aboutToAppear() {
    window.getLastWindow(getContext(this)).then(currentWindow =>{
      let property = currentWindow.getWindowProperties();
      let avoidArea = currentWindow.getWindowAvoidArea(window.AvoidAreaType.TYPE_KEYBOARD);
      // 初始化显示区域高度
      this.screenHeight = px2vp(property.windowRect.height - avoidArea.bottomRect.height);
      // 监视软键盘的弹出和收起
      currentWindow.on('avoidAreaChange', async data => {
        if (data.type !== window.AvoidAreaType.TYPE_KEYBOARD) {
          return;
        }
        this.screenHeight = px2vp(property.windowRect.height - data.area.bottomRect.height);
      })
    })
  }

  build() {
    Row() {
      Column() {
        Text('请输入短信验证码')
          .fontSize(30)
          .margin({
            bottom:'50'
          })
        TextInput()
          .width('70%')
          .height('150px')
          .margin({
            bottom: '30'
          })
        Button('确定')
          .width('70%')
          .margin('20px')
      }
      .width('100%')
    }
    .width('100%').height(this.screenHeight)
  }
}
  • 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.
  • 43.
  • 44.
  • 45.
  • 46.
分享
微博
QQ
微信
回复
2024-12-20 18:25:30
相关问题
HarmonyOS 输入法光标控制
1104浏览 • 1回复 待解决
HarmonyOS 自带输入法输入问题
1109浏览 • 1回复 待解决
HarmonyOS 本地模拟器怎么使用输入法
819浏览 • 1回复 待解决
输入法编程接口吗?
5584浏览 • 1回复 待解决
HarmonyOS如何监听输入法显示隐藏
1489浏览 • 1回复 待解决
如何监听输入法输入内容的变化?
1294浏览 • 1回复 待解决
小程序输入法键盘光标问题
1275浏览 • 1回复 待解决
HarmonyOS 输入法键盘按键的按压效果?
1134浏览 • 2回复 待解决
HarmonyOS 输入法的高度是如何确定的?
1368浏览 • 1回复 待解决