Android:将 EditText 放在 WebView 之上 [英] Android: Put EditText on top of WebView

查看:78
本文介绍了Android:将 EditText 放在 WebView 之上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图通过滚动 WebView 顶部的地址栏来模仿 android 浏览器的行为.如果您注意到,如果用户向下滚动,地址栏会随着 WebView 向上移动"(但 WebView 不会滚动).只有当地址栏完全消失时,WebView 才开始滚动.一开始我试图覆盖 WebView 的 onScrollChanged 方法,并得到了一些东西,但它没有预期的目标那么顺利.我在文档中注意到 WebView 继承自 AbsoluteLayout,所以我想知道是否可以在 WebView 中的浏览器"顶部以编程方式添加一个 View 并由此实现所需的滚动效果?

I have been trying to mimic the behavior of the android browser with the scrolling of the address bar on top of the WebView. If you notice, if the user scrolls down, the address bar "moves" up with the WebView (but the WebView doesn't scroll). Only when the address bar disappears completely the WebView starts to scroll. At first I tried to override the onScrollChanged method of WebView, and got something but it wasn't as smooth as the desired goal. I noticed in the docs that WebView inherits from AbsoluteLayout, so I was wondering if it's possible to add a View programmatically on top the "browser" in the WebView and by that achieve the desired scrolling effect?

编辑

好吧,在浏览本机浏览器应用程序的源代码后,我发现有一个隐藏的方法,称为 setEmbeddedTitleBar(View v)

Ok so after poking around in the source code of the native browser app, I found out that there is an hidden method for that called setEmbeddedTitleBar(View v)

这里是描述(来自Android源):

And here is the description (from the Android source):

 /**Add or remove a title bar to be embedded into the WebView, and scroll
 * along with it vertically, while remaining in view horizontally. Pass
 * null to remove the title bar from the WebView, and return to drawing
 * the WebView normally without translating to account for the title bar.
 * @hide*/

你知道我如何破解我的使用方法吗?

Do you know how I can hack my way to use this ?

推荐答案

您可能仍然可以使用 reflection 来访问它.见:

You could probably still use reflection to access it. See:

这篇关于Android:将 EditText 放在 WebView 之上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆