Is the WebView getContentHeight() broken in 1.5/1.6?

by authoreyes » Thu, 22 Apr 2010 02:10:46 GMT

Sponsored Links
 All -

Urgent issue (and I see other people mentioned it with no resolution),
but how can I force getContentHeight() in the WebView to return an
accurate reading of the currently loaded content?

I have a WebView that needs to occasionally trim content (must display
on one page/no scrollbars).

I have it check the contentHeight onDraw, and it is too much, it trims
it, reloads it, and checks again.

Some times it works, but almost always not.  It always seems to report
the initial content height, as those it caches a value and won't
replace it (which looking at the WebView code, is what it seems to
do).  I can't find a way through the api though, to force it to
remeasure the html content height onDemand.

I am tearing my hair out here...Please anyone have any ideas?


Is the WebView getContentHeight() broken in 1.5/1.6?

by Maps.Huge.Info (Maps API Guru) » Thu, 22 Apr 2010 05:24:39 GMT

 You might try adding a bogus parameter to the end of the URL, such as
a random number or the time, like this:


That will most likely not bollix up the page and make the cache save
that as a unique page.

-John Coryat

"Radar Now!"

"What Zip Code?"


Sponsored Links

Is the WebView getContentHeight() broken in 1.5/1.6?

by authoreyes » Thu, 22 Apr 2010 05:32:57 GMT

 That is an interesting thought.....

Although I am using the loadData method with a string each
time....There is no actual url to speak of...I have tried clearing

It's so odd...The view loads the right data, but the height reports
the original (even though the size is wildly different between loads)
for a few changes, then something causes it to re-eval, etc...

It's not consistent at all, and really annoying...if I can't depend on
this, I am not sure where to go with this current architecture....

On Apr 21, 4:24pm, "Maps.Huge.Info (Maps API Guru)"


Is the WebView getContentHeight() broken in 1.5/1.6?

by Maps.Huge.Info (Maps API Guru) » Thu, 22 Apr 2010 06:27:37 GMT

 You could also try switching to a method that saves the page to the
device and loads it as a URL instead of the direct method that you're
using now, that might get around the issue. Have you tried to test it
with a 2.0+ emulator? Still a problem?

-John Coryat

"Radar Now!"

"What Zip Code?"


Other Threads

1. Error using InstrumentationTestRunner with multiple projects

Thank you everyone for your replies.

I was able to resolve this error. As hinted above, the problem lied in
my project settings.
In my test project, instead of referencing project B directly, I was
able to export the class files from project A.
(Under the "Order and Export" tab in the "Java Build Path" pane.)

This gave me access to all the classes I needed in my test project.

Thanks again for everyone's help.



2. I want to add GLSurfaceView to SurfaceView.

public class CameraStream extends Activity {

        private Preview preview;
        private GLSurfaceView mGLSurfaceView;

        /** Called when the activity is first created. */
        public void onCreate(Bundle savedInstanceState) {


                 preview = new Preview(this);
                 setContentView(preview, new ViewGroup.LayoutParams(200, 200));

                // overview = new OverView(this);
                // addContentView(overview, new ViewGroup.LayoutParams(-1, -1));

                 mGLSurfaceView = new GLSurfaceView(this);
                 mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
                 mGLSurfaceView.setRenderer(new CubeRenderer(true));

                 addContentView(mGLSurfaceView, new ViewGroup.LayoutParams(-1, 

SurfaceView under GLSurfaceView is displayed when describing it like

I want to have them display GLSurfaceView on SurfaceView.


3. Right gravity and hint in EditText is making hint disappear

4. Penjelasan root dan rom..

5. Developer Android Indonesi

6. any good uml creation tool for android?

7. Issues with SDK plugin 0.9.4