Keyboard hides Textarea inside a Hybrd Webview in Xamarin forms

…衆ロ難τιáo~ 提交于 2019-12-23 03:39:36

问题


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


回答1:


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.




回答2:


What about:

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

 global::Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>()
                .UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);



回答3:


Reviewing the documentation at https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/platform-specifics/consuming/android#setting-the-soft-keyboard-input-mode

I think it's better to use:

<Application ...
    xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
    android:Application.WindowSoftInputModeAdjust="Resize">
    ...
</Application>



回答4:


Put your webview inside of a scroll view and handle the focused function , this help me in xamarin forms ios application.

  private void Handle_Focused(object sender, Xamarin.Forms.FocusEventArgs e)
  {
      SCr_View.ScrollToAsync(0, Web_View.Y * 50, false); // 50 is height u want to move up
  }

Try this up.



来源:https://stackoverflow.com/questions/46356840/keyboard-hides-textarea-inside-a-hybrd-webview-in-xamarin-forms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!