Xamarin Forms 3.6 Webview Android:软键盘隐藏了Webview中的输入字段

问题描述 投票:0回答:1

我们有一个Xamarin Forms视图,只有一个工具栏和一个WebView。

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放在ScrollView中时,与Xamarin表单输入字段一起,当软键盘显示时,输入字段向上移动,这意味着AdjustResize行为似乎基本上起作用,但不适用于WebView。

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

有没有人有想法?

android forms xamarin webview android-softkeyboard
1个回答
0
投票

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

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

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.