我一直在尝试通过滚动 WebView 顶部的地址栏来模仿 android 浏览器的行为。如果您注意到,如果用户向下滚动,地址栏会随着 WebView 向上“移动”(但 WebView 不会滚动)。只有当地址栏完全消失时,WebView 才会开始滚动。起初我试图重写 WebView 的 onScrollChanged 方法,并得到了一些东西,但它并不像预期的目标那么顺利。我在文档中注意到 WebView 继承自 AbsoluteLayout,所以我想知道是否有可能以编程方式在 WebView 的“浏览器”顶部添加一个视图,从而实现所需的滚动效果?
编辑
好的,在浏览本机浏览器应用程序的源代码后,我发现有一个隐藏的方法叫做setEmbeddedTitleBar(View v)
这是描述(来自Android来源):
/**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*/
你知道我如何破解我的使用方式吗?