How to center display group in the center of the scroll view? I can center group in another group called fakeScrollView and this is my desired outcome but I can’t do the same with a scroll view.
local widget = require("widget")
widget.setTheme("widget_theme_android")
_G.cx, _G.cy = display.contentCenterX, display.contentCenterY
_G.fullw, _G.fullh = display.actualContentWidth, display.actualContentHeight
local scrollView = widget.newScrollView {
x = cx,
top = 50,
height = fullh-100,
width = fullw,
horizontalScrollDisabled = true,
verticalScrollDisabled = false,
hideBackground = true,
hideScrollBar = true
}
--[[
local fakeScrollView = display.newGroup()
fakeScrollView.anchorChildren = true
fakeScrollView.x, fakeScrollView.y = cx, cy
--]]
local groupY = 0
for i = 1, 10 do
local groupX = 0
for j = 1, 4 do
local group = display.newGroup()
scrollView:insert(group)
group.x = groupX
group.y = groupY
groupX = groupX + 130
local field = display.newRect(group, 0, 0, 100, 100)
field:setFillColor(0 ,0 ,0.4)
end
groupY = groupY + 130
end