webview orientation problem

rthyoung26

Member
Licensed User
Longtime User
Can't control behaviour of the current URL when changing orientation. With the manifest file containing -

SetActivityAttribute(main, android:configChanges, keyboardHidden|orientation)

an orientation change remembers the current URL and location on the page but when changed to landscape the displayed screen only covers the left half of the screen (probably the width of the portrait page) and you can scroll only part way down the page. Seems like the resolution in landscape mode is forced to be the portrait mode. However, with this manifest line (orientation statement removed) -

SetActivityAttribute(main, android:configChanges, keyboardHidden)

the orientation works perfectly in both portrait and landscape mode filling the screen in both cases, but when the orientation occurs, the webview page is returned to the initial page as set in the loadURL command. Same things occurs when going from landscape to portrait or vice versa. Any suggestions on how to keep the current url and page location and still have the full width of the screen used when in landscape mode?
 

NJDude

Expert
Licensed User
Longtime User
This question pops up all the time, so, I've written a simple example to illustrate one of the ways this could be done.

The idea is to save the URL on a variable in Process_Globals, and on Activity_Resume (which triggers when the device is rotated) re-load the url on the WebView.

There are other solutions and ideas in the forums, use the search feature to find them.
 

Attachments

  • PreserveURLOnScreenRotation.zip
    10.8 KB · Views: 605
Upvote 0

youjunjer

Member
Licensed User
Longtime User
This question pops up all the time, so, I've written a simple example to illustrate one of the ways this could be done.

The idea is to save the URL on a variable in Process_Globals, and on Activity_Resume (which triggers when the device is rotated) re-load the url on the WebView.

There are other solutions and ideas in the forums, use the search feature to find them.

The way you use will interrupt the pageloading such as youtube playing
It need to restart form beginning.
Someone knows other way for this condition?
 
Upvote 0
Top