android - Xamarin Forms 3.6 Webview Android:软键盘隐藏 Webview 中的输入字段
问题描述
我们有一个只有一个工具栏和一个 WebView 的 Xamarin 表单视图。
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>
当 WebView 包含 HTML 文本字段并且该字段获得焦点时,软键盘打开但隐藏文本字段。我们目前正在使用 Xamarin.Forms 3.6。我们已经尝试了很多东西,我们在网上找到了这些东西,但还没有奏效。
当我们将 WebView 与 Xamarin Form Entry Field 一起放入 ScrollView 时,输入字段向上移动,当软键盘显示时,这意味着 AdjustResize 行为似乎基本可以正常工作,但不能与 WebView 一起工作。
将 WindowSoftInputMode 设置为 AdjustResize 不会改变任何内容。
有人有想法吗?
解决方案
您可以通过以下步骤解决此问题:
1 使用如下代码检测软键盘是否显示:
var inputMethodManager = (InputMethodManager)this.GetSystemService(Context.InputMethodService);
var keyboardIsShown = inputMethodManager.IsAcceptingText;
2 提交动画以在显示键盘时向上滚动页面。
3 提交动画以在键盘隐藏时向下滚动页面。
推荐阅读
- javascript - 如何在不知道键的情况下使用 javascript/jquery 从多维 json 数组中检索值?
- jquery - 可编辑的小部件在 jQuery tablesorter 中没有响应
- python - “TypeError:不允许使用 `tf.Tensor` 作为 Python `bool`。” 在数据集上调用地图函数时
- python - 使用数据框中的条件删除重复项
- python - 如何从链接中提取经度和纬度
- angular7 - 无法使用 Angular 7 中的链接登录
- android - 如何在 XML 中添加 OR 运算符?
- terraform-provider-azure - Terraform azure 提供程序的 powershell 模块版本依赖项是什么?
- sql - 左连接或内连接
- python - 如何求解不同初始条件的微分方程