Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Can I scale webview? I need to load a page zoomed in 200%
Started by NathanWrzesinski Jul 23 2018 09:32 AM

5 replies to this topic
scale zoom webview showwebpopup

Best Answer Blex , 25 July 2018 - 09:37 AM

This might help out:

https://stackoverflow.com/questions/1156278/how-can-i-scale-an-entire-web-page-with-css\

 

Assuming you can access the CSS. 

 

Honestly, I see nothing wrong with manual zooming...

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

NathanWrzesinski

[GLOBAL: userInfoPane.html]
NathanWrzesinski
  • Observer

  • 2 posts
  • Corona SDK

First of all, Thanks for taking the time to read this post.

I am trying to view a website  through my app but the pages need to be zoomed in 150-200% to read it.

 

You can click the button and it load the page, but you have to manually zoom to read the text. Is there any way that I can automatically zoom in 200%?

Below is the whole code, it's just a bunch of examples pieced together so if you have any advice an syntax I would appreciate that too.

 

 

line 31 : (the web view, but as is the text is far too small and you can not read it without zooming)

 

local function handleButtonEvent( event )

if ( "ended" == event.phase ) then
print( "Button was pressed and released" )

native.showWebPopup( 0,-45, display.contentWidth, display.contentHeight - 40,("http://www.google.com"))
    --//////THIS IS THE PART I AM TRYING TO VIEW, IT NEEDS TO BE ZOOMED IN 200%////////        
end
end

-----------------------------------------------------------------------------------------
--
-- view1.lua
--
-----------------------------------------------------------------------------------------

local composer = require( "composer" )
local scene = composer.newScene()

function scene:create( event )
	local sceneGroup = self.view
	
	-- Called when the scene's view does not exist.
	-- 
	-- INSERT code here to initialize the scene
	-- e.g. add display objects to 'sceneGroup', add touch listeners, etc.
	
	-- create a white background to fill screen
	--local background = display.newRect( display.contentCenterX, display.contentCenterY, display.contentWidth, display.contentHeight )
	--background:setFillColor( .5 )	-- white
	
	
	local background = display.newImageRect( "background1.png", 320, 570 )
background.x = display.contentCenterX
background.y = display.contentCenterY
--add text

local widget = require( "widget" )
 
-- Function to handle button events
local function handleButtonEvent( event )
 
    if ( "ended" == event.phase ) then
        print( "Button was pressed and released" )

        native.showWebPopup( 0,-45, display.contentWidth, display.contentHeight - 40,("http://www.theaustinexplorer.com/?m=1"))
	--//////THIS IS THE PART I AM TRYING TO VIEW, IT NEEDS TO BE ZOOMED IN 200%////////		
    end
end
 





local button1 = widget.newButton(
    {
        width = 173,
        height = 47,
        labelColor = { default={ 1, 1, 1 }, over={ 1, 1, 1, 1 } },
        defaultFile = "button9.png",
        overFile = "button8.png",
        label = "button",
        onEvent = handleButtonEvent
    }
)
 
-- Center the button
button1.x = display.contentCenterX
button1.y = display.contentCenterY
 
-- Change the button's label text
button1:setLabel( " JUMP! " )
	
	-- all objects must be added to group (e.g. self.view)
	--sceneGroup:insert( background )
	--sceneGroup:insert( title )
	--sceneGroup:insert( summary )
end

function scene:show( event )
	local sceneGroup = self.view
	local phase = event.phase
	
	if phase == "will" then
		-- Called when the scene is still off screen and is about to move on screen
	elseif phase == "did" then
		-- Called when the scene is now on screen
		-- 
		-- INSERT code here to make the scene come alive
		-- e.g. start timers, begin animation, play audio, etc.
	end	
end

function scene:hide( event )
	local sceneGroup = self.view
	local phase = event.phase
	
	if event.phase == "will" then
		-- Called when the scene is on screen and is about to move off screen
		--
		-- INSERT code here to pause the scene
		-- e.g. stop timers, stop animation, unload sounds, etc.)
	elseif phase == "did" then
		-- Called when the scene is now off screen
	end
end

function scene:destroy( event )
	local sceneGroup = self.view
	
	-- Called prior to the removal of scene's "view" (sceneGroup)
	-- 
	-- INSERT code here to cleanup the scene
	-- e.g. remove display objects, remove touch listeners, save state, etc.
end

---------------------------------------------------------------------------------

-- Listener setup
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )


-----------------------------------------------------------------------------------------

return scene

Any advice you have would be helpful! Thank you for reading!



[TOPIC: post.html]
#2

dodi_games

[GLOBAL: userInfoPane.html]
dodi_games
  • Contributor

  • 370 posts
  • Corona SDK

Native display objects are a little limited in Corona SDK. I don't see anything here related to zoom in the native web view content.

 

DoDi



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,648 posts
  • Enterprise

There really isn't a Corona way to do this. If the webView offers a zoom option, the user can tap on the zoom option, but I'm not sure how to do it programmatically.

 

You might have some success messing with CSS settings in the <head> tag of the HTML if you have access to it, but that wouldn't be Corona specific.

 

Rob



[TOPIC: post.html]
#4

Blex

[GLOBAL: userInfoPane.html]
Blex
  • Corona Geek

  • 1,199 posts
  • Corona SDK

  Best Answer

This might help out:

https://stackoverflow.com/questions/1156278/how-can-i-scale-an-entire-web-page-with-css\

 

Assuming you can access the CSS. 

 

Honestly, I see nothing wrong with manual zooming...



[TOPIC: post.html]
#5

NathanWrzesinski

[GLOBAL: userInfoPane.html]
NathanWrzesinski
  • Observer

  • 2 posts
  • Corona SDK

I can, but I don't want the website zoomed in 150% when viewing on a computer. Is there a conditional if android, then zoom I could use?



[TOPIC: post.html]
#6

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 956 posts
  • Corona SDK

Yes. Check the documentation for

system.getInfo()

This method can tell you plenty of stuff about the platform running the application.




[topic_controls]
[/topic_controls]