【问题标题】:Xamarin Forms 3.6 Webview Android: Softkeyboard hides entry fields in WebviewXamarin Forms 3.6 Webview Android:软键盘隐藏 Webview 中的输入字段
【发布时间】:2019-03-22 13:34:33
【问题描述】:

我们有一个只有一个工具栏和一个 WebView 的 Xamarin 表单视图。

ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         Title="TestApp"
         x:Class="TestApp.Client.Views.MainPage">
<ContentPage.ToolbarItems>
    <ToolbarItem
        Order="Primary" 
        Icon="ic_settings.png"
        Clicked="OnSettingsClicked"
        AutomationId="mnuSettings"
        Priority="1"
        x:Name="mnuSettings"
        Text="Settings"
    />
</ContentPage.ToolbarItems>
<WebView"
    Source="{Binding URL}">
</WebView>

当 WebView 包含 HTML 文本字段并且该字段获得焦点时,软键盘打开但隐藏文本字段。我们目前正在使用 Xamarin.Forms 3.6。我们已经尝试了很多东西,我们在网上找到了这些东西,但还没有奏效。

当我们把 WebView 和 Xamarin Form Entry Field 一起放在一个 ScrollView 里面时,当软键盘显示时,entry field 向上移动,这意味着 AdjustResize 行为似乎基本可以工作,但不能与 WebView 一起工作。

将 WindowSoftInputMode 设置为 AdjustResize 不会改变任何内容。

有人有想法吗?

【问题讨论】:

    标签: android forms xamarin webview android-softkeyboard


    【解决方案1】:

    您可以通过以下步骤解决此问题:

    1 使用以下代码检测是否显示软键盘:

        var inputMethodManager = (InputMethodManager)this.GetSystemService(Context.InputMethodService);
        var keyboardIsShown = inputMethodManager.IsAcceptingText;
    

    2 提交动画以在键盘显示时向上滚动页面。

    3 提交动画以在键盘隐藏时向下滚动页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-20
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多