Bug 50792 - WebView doesn't get resized or panned when soft keyboard is overlayed
Summary: WebView doesn't get resized or panned when soft keyboard is overlayed
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-12-26 03:11 UTC by DongHeon
Modified: 2017-09-12 16:07 UTC (History)
8 users (show)

Tags: android
Is this bug a regression?: ---
Last known good build:

The soft keyboard hides input field. (68.19 KB, image/jpeg)
2016-12-26 03:11 UTC, DongHeon

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description DongHeon 2016-12-26 03:11:04 UTC
Created attachment 18991 [details]
The soft keyboard hides input field.

I'm using Xamarin Forms, and testing on Lollipop emulator.

When the input field in a WebView get focused, the software keyboard is scrolling up and the input field is overlayed.
The keyboard hides the focused input field as shown in the screenshots.

If I create and click a Entry rather than the WebView, it resizes the content page as expected.
I've searched a lot with this issue but none of them works with WebView case.(including setting WindowSoftInputMode = SoftInput.AdjustResize on Activity)

I can say this behavior in Xamarin.Forms is buggy because If I create a WebView in Android with Activity rather than FormsAppCompatActivity, the WebView is scrolled up OK.

My sample code is just simple webview loading stackoverflow page. (http://pastebin.com/GFVCgDEt)
Comment 1 adrianknight89 2016-12-26 17:52:34 UTC
Instead of wrapping the WebView inside a ScrollView, just use WebView. It seems to work. 

Also use


in App constructor. This might be a workaround rather than an actual fix.
Comment 2 adrianknight89 2016-12-26 19:28:45 UTC
Note that if you use Resize, then a white strip appears at the top and a blue strip below that. The fix is to use https://github.com/xamarin/Xamarin.Forms/pull/552 so that the status bar underlay can be toggled off. The underlay is only needed in the case of master detail pages.
Comment 3 DongHeon 2016-12-27 07:32:39 UTC
Thanks for you comment adrianknight89.

I've removed ScrollView and added below line in App Constructor


But, that cause following exception.

Process: App1.Droid, PID: 20245
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
	... 1 more
Caused by: android.runtime.JavaProxyThrowable: System.TypeLoadException: Could not resolve type with token 01000011
  at App1.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00027] in <f1ff156807bb4f538bbcdcf03847777f>:0 
  at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <27c17fe440cf491ba8255bcefade6e02>:0 
  at (wrapper dynamic-method) System.Object:1578db63-0dfa-4f7a-9499-2046df97796b (intptr,intptr,intptr)
	at md50170a25da682dd459b9251c65ebe3a7a.MainActivity.n_onCreate(Native Method)
	at md50170a25da682dd459b9251c65ebe3a7a.MainActivity.onCreate(MainActivity.java:29)
	at android.app.Activity.performCreate(Activity.java:5990)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
	at android.app.ActivityThread.access$800(ActivityThread.java:151)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5254)
	... 4 more
Comment 4 DongHeon 2016-12-27 07:38:24 UTC
Anyway, I wonder whether this problem is a known bug and will Xamarin team fix it rather than applying a workaround.
Comment 5 DongHeon 2016-12-28 14:36:40 UTC
I tested this on Xamarin Forms, and the problem didn't happen. It only happens in 2.3.x versions.
Comment 6 DongHeon 2016-12-29 02:13:13 UTC
It works OK on only with FormsApplicationActivity, not with FormsAppCompatActivity.
Comment 7 DongHeon 2016-12-29 06:43:00 UTC
I figured out that adrianknight89's workaround actually works in
And I can see a unwanted white strip at top. I haven't applied adrianknight89's patch to fix that.

cf. The exception in my previous comment was from the custom components in my project. (https://github.com/pocheshire/BottomNavigationBar, https://github.com/thrive-now/BottomNavigationBarXF)
Comment 8 adrianknight89 2017-02-12 23:13:45 UTC
Ideally. my PR shouldn't be needed. They need to fix MasterDetailPage. Until then, we need workarounds to get rid of the white strip.
Comment 9 Osman Sönmez 2017-04-08 04:36:47 UTC
if you have keyboard scroll problem with xamarin webview or xamarin hybridwebview use this code below in your App.cs


All my App.cs

public App()
            MainPage = new NavigationPage(new EmptyNavigationPage());

Comment 10 Oleg V. 2017-04-24 18:49:49 UTC
Thanks guys for sharing your workarounds!

> Until then, we need workarounds to get rid of the white strip.
@adrianknight89, you mentioned workaround for white strip, however, I see only patch for Xamarin.Forms.

Is this possible to workaround in my own code?
Comment 11 E.Z. Hart [MSFT] 2017-05-30 21:37:52 UTC
The white strip problems should be fix in 2.3.6 (with PR https://github.com/xamarin/Xamarin.Forms/pull/892).
Comment 12 jmalbarran 2017-09-12 16:07:42 UTC
Hi, Osman

Could you share you XAML?

I'm trying to use your solution, but it's not working for me.

I have some differences, but before start changing code, I'd like to have a code working.

BTW, my differences:

1) I don't use a NavigationPage, I use directly the page (so I don't have AppBar/Toolbar)
2) I have a custom renderer for the WebView. Maybe have I to add some code there

========= App.xaml.cs
using System.Linq;
using System.Text;
using Xamarin.Forms.PlatformConfiguration;

using Xamarin.Forms;

namespace AhorraLum {
  public partial class App : Application {
    public App() {

      // JMA: Scroll up when soft keyboard is shown
#if __ANDROID__
      Xamarin.Forms.PlatformConfiguration.AndroidSpecific.Application.SetWindowSoftInputModeAdjust(this, Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust.Resize);


			MainPage = new AhorraLum.MainPage();

		protected override void OnStart ()
			// Handle when your app starts

		protected override void OnSleep ()
			// Handle when your app sleeps

		protected override void OnResume ()
			// Handle when your app resumes
========= End App.xaml.cs

========= MainPage.xaml
<?xml version="1.0" encoding="UTF-8"?>
  xmlns     ="http://xamarin.com/schemas/2014/forms"
  xmlns:x    ="http://schemas.microsoft.com/winfx/2009/xaml"
  x:Class    ="AhorraLum.MainPage"
  Title      ="AhorraLum">
        x:Name                     ="Loading"
        HorizontalOptions          ="FillAndExpand"
        VerticalOptions            ="Center"
        AbsoluteLayout.LayoutFlags ="All"
        IsVisible                  ="True"
        Orientation                ="Vertical">
          x:Name                 ="LoadingLabel"
          Text                   ="Cargando..."
          HorizontalOptions      ="FillAndExpand"
          HorizontalTextAlignment="Center" />
          Color    ="Green"
          IsRunning="True" />
        x:Name                     ="Browser"
        Alert                      ="OnAlert"
        Confirm                    ="OnConfirm"
        Navigating                 ="OnCustomNavigating"
        Navigated                  ="OnNavigated"
        AbsoluteLayout.LayoutFlags ="All"
        HorizontalOptions          ="FillAndExpand"
        VerticalOptions            ="FillAndExpand"
        IsVisible                  ="True" />
        x:Name                     ="Browser"
        Navigating                 ="OnNavigating"
        Navigated                  ="OnNavigated"
        AbsoluteLayout.LayoutFlags ="All"
        HorizontalOptions          ="FillAndExpand"
        VerticalOptions            ="FillAndExpand"
        IsVisible                  ="False" />
============ End MainPage.xaml