I’m having a number of strange issues in regards to the ScrollView widget and G2. I’ve tried to put together a simple piece of code to show the issues, as well as some video demonstrating them as well.
I am running into 3 issues:
-
The ScrollView does not seem to update itself visually until I move it. Even a tiny nudge will make it appear, but does not show on its own. I’ve also tried a short delay before rendering the ScrollView, but it made no difference.
-
Setting the scrollWidth when instantiating the widget does not seem to work. But…it can be adjusted after the fact using setScrollWidth.
-
I could be misunderstanding how the anchors work, but even when trying to place the widget at a 0 x and y, and anchorX and anchorY to 0 it still seems to scroll the starting point to the middle of the screen, but it does seem to start at the proper spot (though its hard to tell because of the issue #1). Again, this could be a misunderstanding on my part.
You can view the screencast here.
Code:
[lua]local widget = require( “widget” )
local function renderScrollView()
local function scrollListener( event )
–print(‘event’)
end
local scrollView = widget.newScrollView
{
width = display.contentWidth,
height = 240,
–scrollWidth = 6200,
scrollHeight = 0,
verticalScrollEnabled = false,
isBounceEnabled = false,
hideScrollBar = true,
hideBackground = true,
listener = scrollListener,
}
for i=1, 20 do
local g = display.newGroup()
local btn = display.newRect( 0, 0, 200, 200 )
btn:setFillColor( 128 )
btn.x = 250 * i
g:insert( btn )
local text = display.newText({
text = “item” … i,
width = 220,
height = 0,
font = native.systemFont,
fontSize = 42,
align = “center”
})
text:setFillColor( 0 )
text.x = btn.x
text.y = btn.y - 10
g:insert( text )
scrollView:insert( g )
end
scrollView.anchorX = 0
scrollView.anchorY = 0
scrollView.x = 0
scrollView.y = 0
scrollView:setScrollWidth( 6200 )
end
renderScrollView()[/lua]
Build 2047 - Windows 8.1 - Nexus 4 - Kindle HDX
As an additional note, the last version that seems to work consistently with the ScrollView is Build 2026.
Can anyone confirm this? Is this a possible bug?
Best.