Luk4
Luk4

Reputation: 13

Resize webview when I show the keyboard

I created a webview (xamarin - Android) but when I press on a textbox the keyboard is positioned above the webview and there is a button positioned at the bottom of the page. The webview is not resized. On Chrome the button is on top of the keyboard

Upvotes: 0

Views: 1752

Answers (2)

iyepes
iyepes

Reputation: 145

Another solution documented here https://forums.xamarin.com/discussion/85024/webview-doesnt-get-resized-or-panned-when-soft-keyboard-is-overlayed

In the constructor in App.xaml.cs:

using AndroidSpecific = Xamarin.Forms.PlatformConfiguration.AndroidSpecific;

namespace yournamespace
{
public partial class App : Application
{
    public App()
    {
        InitializeComponent();
        AndroidSpecific.Application.SetWindowSoftInputModeAdjust(this, AndroidSpecific.WindowSoftInputModeAdjust.Resize);
        //your init code
    }
}
}

Upvotes: 2

York Shen
York Shen

Reputation: 9084

Add WindowSoftInputMode = Android.Views.SoftInput.AdjustResize to your Activity attribute:

[Activity(Label = "@string/app_name", 
    MainLauncher = true, 
    LaunchMode = Android.Content.PM.LaunchMode.SingleTop, 
    Icon = "@drawable/icon",
    WindowSoftInputMode = Android.Views.SoftInput.AdjustResize)]
public class MainActivity : AppCompatActivity

Upvotes: -1

Related Questions