Webview Orientation problems

Hello,

I’m a little disappointed about a problem since a few days,

I wanted to implement webview with Corona Sdk and deploy it on my nexus 7.

But i’m in front of a problem i can’t resolve actually and this very embarassing.

When i’m trying to change my tablet orientation my webview is not correctly resized, let me show you with screenshots.

It should be very helpful from your own to help me , try a lot of thing but without success…

i post a snippet of my code here, and hope someone can afford a solution…

Thanks…

I don’t know if you have resolved this problem but the way i handle webview orientation change is to remove the current webview and rebuilt it for the new orientation. There seems to be an issue with resizing the native webview. Here is a sample of my code that I have in an application that will rebuild the webview for a new orientation and it when it rebuilds the webview it will display the same site that the user was on when the orientation changed.

[lua]
local lastLink = “”
local webWin

–Listener Function
local function webListener (event)

     --Set Last Link
     lastLink = event.url

     --Spinner
     if event.type == “loaded” then

          --Remove Spinner
          if system.getInfo(“platformName”) == “Android” then
               native.setActivityIndicator( false )
          end

     elseif event.errorCode then

          --Native on Complete Function
          local function onComplete ()
               --Close Web View
               if webWin then webWin:removeSelf(); webWin = nil; end
          end

          --Remove Spinner
          local spinnerTimer = timer.performWithDelay (500, function () if system.getInfo(“platformName”) == “Android” then native.setActivityIndicator( false ) end; end, 1)

          --Native Popup
          local noService = native.showAlert( “Error”, “There was an error loading the webpage. Please try again later.”, {“OK”}, onComplete )
     end
end

–New Web Window
webWin = native.newWebView(display.screenOriginX, display.screenOriginY, display.contentWidth + (math.abs (display.screenOriginX) * 2), display.contentHeight + (math.abs (display.screenOriginY) * 2))

–Request Web Page
webWin:request (“http://www.GBCConnected.org”)

–Add Listener
webWin:addEventListener( “urlRequest”, webListener )

–Orientation Listener
local function checkOri (event)

      --Remove Web Window
     if webWin then webWin:removeSelf(); webWin = nil; end

     --Create Web Window in New Orientation
     webWin = native.newWebView(display.screenOriginX, display.screenOriginY, display.contentWidth + (math.abs (display.screenOriginX) * 2), display.contentHeight + (math.abs (display.screenOriginY) * 2))

     --Call Web Win
     webWin:request (lastLink)

     --Add Listener
     webWin:addEventListener( “urlRequest”, webListener )

end
Runtime:addEventListener (“orientation”, checkOri)[/lua]

I don’t know if you have resolved this problem but the way i handle webview orientation change is to remove the current webview and rebuilt it for the new orientation. There seems to be an issue with resizing the native webview. Here is a sample of my code that I have in an application that will rebuild the webview for a new orientation and it when it rebuilds the webview it will display the same site that the user was on when the orientation changed.

[lua]
local lastLink = “”
local webWin

–Listener Function
local function webListener (event)

     --Set Last Link
     lastLink = event.url

     --Spinner
     if event.type == “loaded” then

          --Remove Spinner
          if system.getInfo(“platformName”) == “Android” then
               native.setActivityIndicator( false )
          end

     elseif event.errorCode then

          --Native on Complete Function
          local function onComplete ()
               --Close Web View
               if webWin then webWin:removeSelf(); webWin = nil; end
          end

          --Remove Spinner
          local spinnerTimer = timer.performWithDelay (500, function () if system.getInfo(“platformName”) == “Android” then native.setActivityIndicator( false ) end; end, 1)

          --Native Popup
          local noService = native.showAlert( “Error”, “There was an error loading the webpage. Please try again later.”, {“OK”}, onComplete )
     end
end

–New Web Window
webWin = native.newWebView(display.screenOriginX, display.screenOriginY, display.contentWidth + (math.abs (display.screenOriginX) * 2), display.contentHeight + (math.abs (display.screenOriginY) * 2))

–Request Web Page
webWin:request (“http://www.GBCConnected.org”)

–Add Listener
webWin:addEventListener( “urlRequest”, webListener )

–Orientation Listener
local function checkOri (event)

      --Remove Web Window
     if webWin then webWin:removeSelf(); webWin = nil; end

     --Create Web Window in New Orientation
     webWin = native.newWebView(display.screenOriginX, display.screenOriginY, display.contentWidth + (math.abs (display.screenOriginX) * 2), display.contentHeight + (math.abs (display.screenOriginY) * 2))

     --Call Web Win
     webWin:request (lastLink)

     --Add Listener
     webWin:addEventListener( “urlRequest”, webListener )

end
Runtime:addEventListener (“orientation”, checkOri)[/lua]