简体   繁体   English

如何知道何时在Android WebView中关注文本字段?

[英]how to know when and where a textfield is focused in an android webview?

Normally when a native textfield in an android view is focused, the view scrolls automatically to keep the field visible when the virtual keyboard appears. 通常,当对android视图中的本机文本字段进行聚焦时,当虚拟键盘出现时,视图会自动滚动以使该字段可见。 And it's normally the same behaviour when I select a textfield in a webview (so I mean a html text input in the page that loaded in the webview). 当我在Web视图中选择文本字段时,通常是相同的行为(因此,我的意思是在Web视图中加载的页面中输入html文本)。 But for some reason, it doesn't work in my case. 但是出于某种原因,在我的情况下它不起作用。 I have a webview that displays a form and when a select a textfield, the view scrolls down to the bottom of the page and the field I selected is no longer visible. 我有一个显示表单的Web视图,当选择一个文本字段时,该视图向下滚动到页面底部,并且我选择的字段不再可见。 What should I check in my app to prevent this to happen? 我应该在我的应用程序中进行哪些检查以防止这种情况发生? If you need more details, just ask. 如果您需要更多详细信息,请询问。 In this way I can show you directly what you need. 这样,我可以直接向您显示您的需求。 Thanks in advance. 提前致谢。

EDIT: on android 4, this is not happening. 编辑:在android 4上,这没有发生。 I encountered the problem on android 2.2 and 2.3. 我在android 2.2和2.3上遇到了问题。

android:windowSoftInputMode="adjustResize" android:windowSoftInputMode =“ adjustResize”

Add above tag in your manifest file's activity tag. 在清单文件的活动标签中添加上述标签。 The activity will be the one which displays webview 该活动将是显示webview的活动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 重点关注WebView时未触发Android webview onBackPressed - Android webview onBackPressed not fired when WebView is focused 单击WebView中的TextField时如何控制android中WebView的缩放 - How to control the Zoom of a WebView in android when a TextField in WebView is Clicked 如何知道Android中何时将列表视图中的列表项聚焦(突出显示)? - How to know when a listitem in a listview is focused(highlighted) in Android? 如何知道 WebRTC 何时连接在 android (webview) 中? - how to know when WebRTC is connected in android (webview)? 如何知道ListView的最后一项是专注于android? - How to know last item of ListView is focused in android? 当文本字段集中在Android的代号中的webbrowser组件上时键盘不显示 - Keyboard not showing when textfield is focused on webbrowser component in codename for android 当textField聚焦时显示TimePicker - Display TimePicker when textField is focused 如何使用iscroll和Android WebView将焦点字段引入视图 - How to bring focused field into the view using iscroll and Android WebView Android Webview 如何删除加载元素的聚焦/悬停 state? - Android Webview how to remove focused/hovered state of an element on load? 焦点时如何将EditText移到顶部? - android - How to shift EditText to top when focused?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM