Question

I need to get the width and height of a WebView and pass them in the query string of the URL I am loading in the WebView. I have found a way to do this in onResume(). Since the width and height are not calculated at this point, I post a Runnable to the WebView to be queued for after the UI loads.

Here's my problem: when the orientation changes, I am handling it in onConfigurationChanged. When I try to post a Runnable in onConfigurationChanged to the WebView, the WebView's width and height end up being the old orientation's width and height. At what point can I intercept the new width and height after orientation change?

Was it helpful?

Solution

Use a ViewTreeObserver, for an example check out this answer: https://stackoverflow.com/a/8245468/757073

OTHER TIPS

Try in onPostResume. This gets called after onResume, which is supposed to be called when it gets ready to put it on screen.

This only works with the parent view or getRootView() it returns the same ht and wd for the child view.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top