[SOLVED] Scrollview size incorrect on tablet

Hi, I use a vertical scrollview to display an image (719x3200) containing the rules of my game.

The image is “fullscreen” on mobile Wiko Wax (720x1280 - Android 4.3) and simulator in any resolution but on tablet Samsung Galaxy Tab 2 (800x1280) the width of the scrollview is not correct.

 local scrollview = widget.newScrollView{ backgroundColor = {0,0,0}, x = 0, y = 0, width = display.contentWidth, height = display.contentHeight-90, scrollWidth = display.contentWidth, scrollHeight = 3200, horizontalScrollDisabled = true, } local img=display.newImage("rules.png") --719x3200 scrollview:insert(img)

rules.png

As you can see, only the half of the screen is filled… An idea?

Hi @waltsir,

What option for “scale” are you using in your “config.lua”? “letterbox”? “zoomEven”? “adaptive”? Can you post the entire contents of your “config.lua” so I can inspect it?

Thanks,

Brent

Hi! Here’s my config.lua

application = { content = { width = 720, height = 1280, scale = "letterbox", xAlign = "center", yAlign = "center", fps=60, } }

Hi @waltsir,

Can you change the background color of the ScrollView to something that isn’t black? And then post another screenshot so I can see exactly what the bounds of it are?

Thanks,

Brent

Hi! I changed the picture by a stripped one which is 720x3200 and changed the widget’s background color in green. Again, only the half is filled… This device has Android 4.1.2 and I use build 2015.2731.

rules_strip.png

Ok thanks. And you report that the results are totally different on the Wiko Wax device?

Yes, it’s it works, even on another device (Wiko Stairway, Android 4.2.1). I have to mention I use the following:

display.setDefault(“anchorX”,0)
display.setDefault(“anchorY”,0)

It’s maybe the source of the problem for the Galaxy Tab 2

Hi @waltsir,

The default anchors may be the cause. Can you remove the defaults and see what happens? Perhaps assign anchors of 0,0 to specific objects that require it, instead of using 0,0 for everything?

Brent

I used the default anchors (0.5; 0.5) with the following code:

local scrollview = widget.newScrollView{ backgroundColor = {0,0,1}, x = display.contentCenterX, y = display.contentCenterX, width = display.contentWidth, height = display.contentHeight, scrollWidth = display.contentWidth, scrollHeight = 3200, horizontalScrollDisabled = true, } local img=display.newImage("rules.png",display.contentCenterX,display.contentCenterY+(3200-display.contentHeight)/2) scrollview:insert(img)

On simultor and phones it works perfectly but on the tablet, the image is now horizontally centered but still not fullscreen.

Hi @waltsir,

This is likely because you’re not using dynamically-selected images. I highly recommend that you do… it’s virtually a necessity for modern app development across a wide array of devices.

Best regards,

Brent

Thanks for the tips :wink:
By the way I coded my own scrollview and I had exactly the same result than the widget! I suspected the problem comes from the big size of the image on that “old” device which has probably textures limits

SOLVED!!

It’s because of the device texture size which is limited to 1024x1024. So I splitted the image in 5 parts (1024 pixels max) and now it’s fullscreen. in fact, it seems images could have width or height larger than 1024 but not both.

 local scroll=display.newGroup() local ypos=0 for i=1,5 do local img=display.newImage(scroll,"rules"..i..".png",0,ypos) ypos=ypos+img.height end local scrollview = widget.newScrollView{ backgroundColor = {0,0,0}, x = 0, y = 0, width = display.contentWidth, height = display.contentHeight, scrollWidth = display.contentWidth, scrollHeight = ypos, horizontalScrollDisabled = true, } scrollview:insert(scroll)

Hi @waltsir,

What option for “scale” are you using in your “config.lua”? “letterbox”? “zoomEven”? “adaptive”? Can you post the entire contents of your “config.lua” so I can inspect it?

Thanks,

Brent

Hi! Here’s my config.lua

application = { content = { width = 720, height = 1280, scale = "letterbox", xAlign = "center", yAlign = "center", fps=60, } }

Hi @waltsir,

Can you change the background color of the ScrollView to something that isn’t black? And then post another screenshot so I can see exactly what the bounds of it are?

Thanks,

Brent

Hi! I changed the picture by a stripped one which is 720x3200 and changed the widget’s background color in green. Again, only the half is filled… This device has Android 4.1.2 and I use build 2015.2731.

rules_strip.png

Ok thanks. And you report that the results are totally different on the Wiko Wax device?

Yes, it’s it works, even on another device (Wiko Stairway, Android 4.2.1). I have to mention I use the following:

display.setDefault(“anchorX”,0)
display.setDefault(“anchorY”,0)

It’s maybe the source of the problem for the Galaxy Tab 2

Hi @waltsir,

The default anchors may be the cause. Can you remove the defaults and see what happens? Perhaps assign anchors of 0,0 to specific objects that require it, instead of using 0,0 for everything?

Brent

I used the default anchors (0.5; 0.5) with the following code:

local scrollview = widget.newScrollView{ backgroundColor = {0,0,1}, x = display.contentCenterX, y = display.contentCenterX, width = display.contentWidth, height = display.contentHeight, scrollWidth = display.contentWidth, scrollHeight = 3200, horizontalScrollDisabled = true, } local img=display.newImage("rules.png",display.contentCenterX,display.contentCenterY+(3200-display.contentHeight)/2) scrollview:insert(img)

On simultor and phones it works perfectly but on the tablet, the image is now horizontally centered but still not fullscreen.