HarmonyOS Web输入框中键盘mode模式问题

Web页面中的input输入框,点击输入框弹出键盘,是抬起的模式,对组件设置:

windowStage.getMainWindowSync().getUIContext().setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE);  
  • 1.

不起作用,想要的是,弹出键盘后,键盘是遮盖到页面上,不改变原有Web的UI。

HarmonyOS
2024-12-26 16:29:39
915浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

可以考虑使用layoutMode自适应布局,并将Web组件内嵌到可滚动容器实现页面滑动:

import web_webview from '@ohos.web.webview'
import { KeyboardAvoidMode } from '@ohos.arkui.UIContext'
import window from '@ohos.window';
import { BusinessError } from '@ohos.base';
@Entry
@Component
struct WebComponent {
  private scrollerForScroll: Scroller = new Scroller()
  controller: web_webview.WebviewController = new web_webview.WebviewController();
  // scroll竖向的滚动
  @State ScrollDirection: ScrollDirection = ScrollDirection.Vertical
  build() {
    Flex() {
      Scroll(this.scrollerForScroll) {
        Column({ space: 5 }) {
          Web({ src: $rawfile('web2.html'), controller: this.controller })
            .nestedScroll({
              scrollForward: NestedScrollMode.SELF_FIRST,
              scrollBackward: NestedScrollMode.SELF_FIRST
            })
            .height("100%")
            .width("100%")
            .layoutMode(WebLayoutMode.FIT_CONTENT)
        }.width("95%")
      }
      .scrollBar(BarState.Off)
      .width("100%")
      .height("120%")
      .scrollable(this.ScrollDirection)
    }.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.
分享
微博
QQ
微信
回复
2024-12-26 18:08:51


相关问题
HarmonyOS web中的输入框键盘遮住
752浏览 • 1回复 待解决
HarmonyOS 键盘遮挡输入框
751浏览 • 1回复 待解决
HarmonyOS 输入框与软键盘问题
874浏览 • 1回复 待解决
HarmonyOS 输入框屏蔽系统键盘
692浏览 • 1回复 待解决
HarmonyOS 自定义键盘输入框焦点问题
985浏览 • 1回复 待解决
HarmonyOS 如何控制输入框弹出键盘
1031浏览 • 1回复 待解决
HarmonyOS 适配-输入框问题
848浏览 • 1回复 待解决
HarmonyOS webview里的输入框键盘覆盖
725浏览 • 1回复 待解决
HarmonyOS 自定义键盘不能顶起输入框
1266浏览 • 1回复 待解决
HarmonyOS 自定义键盘弹起后遮住输入框
1526浏览 • 1回复 待解决