0
votes

We have a Xamarin Forms View with just a Toolbar and a 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>

When the WebView contains a HTML text field and the field gets the focus, the soft keyboard opens but hides the text field. We are currently using Xamarin.Forms 3.6. We have tried already many things, which we found on th web, but nothing worked, yet.

When we put the WebView inside a ScrollView, together with an Xamarin Form Entry Field, the entry field moves up, when the soft keyboard displays, which means that the AdjustResize behavior seems to work basically, but not with the WebView.

Setting the WindowSoftInputMode to AdjustResize does not change anything.

Does anyone have an idea?

1

1 Answers

0
votes

You can solve this problem by the following steps:

1 Detect whether soft keyboard is showing using code like:

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

2 Commit an animation to scroll up the page when keyboard is showing.

3 Commit an animation to scroll down the page when keyboard is hidden.