1

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?


EDIT

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)

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 ?

Alex1987
  • 9,397
  • 14
  • 70
  • 92

2 Answers2

0

As far as I can see this method is public. So you can use it I think.

I've just looked through its implementation. It just calls addView() method of WebView object. So if you don't want to use hidden method you can reimplement this method.

Michael
  • 53,859
  • 22
  • 133
  • 139
  • Eclipse gives me an error when I try to use it. Believe me I tried. And reimplementing this method is also problematic because there are hidden methods and variables in that method, so I will end up adding to my project the whole WebKit source, and even more, which is something I try to avoid. – Alex1987 Feb 24 '11 at 22:14
0

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

Community
  • 1
  • 1
Joseph Earl
  • 23,351
  • 11
  • 76
  • 89
  • Be warned that you are not guaranteed this will work on future Android versions. So you'll probably want to give the user a message or add alternate UI controls if attempting to access the method fails. – Joseph Earl Feb 27 '11 at 12:47