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

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

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

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

HarmonyOS
2024-12-26 16:29:39
浏览
收藏 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%')
  }
}
分享
微博
QQ
微信
回复
2024-12-26 18:08:51
相关问题
HarmonyOS web中的输入框键盘遮住
407浏览 • 1回复 待解决
HarmonyOS 键盘遮挡输入框
307浏览 • 1回复 待解决
HarmonyOS 输入框屏蔽系统键盘
287浏览 • 1回复 待解决
HarmonyOS 输入框与软键盘问题
413浏览 • 1回复 待解决
HarmonyOS 如何控制输入框弹出键盘
503浏览 • 1回复 待解决
HarmonyOS 自定义键盘输入框焦点问题
524浏览 • 1回复 待解决
HarmonyOS 适配-输入框问题
415浏览 • 1回复 待解决
HarmonyOS 自定义键盘不能顶起输入框
830浏览 • 1回复 待解决
HarmonyOS webview里的输入框键盘覆盖
370浏览 • 1回复 待解决