Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard hides Textarea inside a Hybrd Webview in Xamarin forms

In xamarin forms I am making use of hybrid webview to display texarea and entry fields.When I try to enter some data inside the textarea the keyboard pops up and hides the textarea.
Thus I am not able to see the text that i'm typing.It does not auto scroll to the current cursor position.I have read that adding
android:windowSoftInputMode="adjustResize" to the android manifest file does the trick.
But is it possible to apply the above property to only the webview(without applying for other views)?Or is there any other way to auto scroll the view so that entry field(cursor)is just above the keyboard.
Please help

like image 520
Debasish Avatar asked Dec 07 '22 16:12

Debasish


2 Answers

In App.xaml.cs you can add:

using AndroidSpecific = Xamarin.Forms.PlatformConfiguration.AndroidSpecific;

public App()
{
    InitializeComponent();
    AndroidSpecific.Application.SetWindowSoftInputModeAdjust(this, AndroidSpecific.WindowSoftInputModeAdjust.Resize);
    …

Which I guess is less idiomatic than Artūras Paleičikas' answer but achieves the same affect.

like image 174
David Clarke Avatar answered Dec 10 '22 11:12

David Clarke


What about:

protected override void OnCreate(Bundle savedInstanceState)
{
...

 global::Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>()
                .UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
like image 22
Artūras Paleičikas Avatar answered Dec 10 '22 11:12

Artūras Paleičikas