newScrollView bug?

Hi,

I’m having issue with Scrollview. I insert 9 rectangle into a scrollview but when i am scrolling to the last rectangle on the right it is “out of the device screen”. what is the solution to get it into the screen?

here is my code  : 

display.setStatusBar( display.HiddenStatusBar ) local widget = require( "widget" ) -- Our ScrollView listener local function scrollListener( event ) local phase = event.phase local direction = event.direction if "began" == phase then --print( "Began" ) elseif "moved" == phase then --print( "Moved" ) elseif "ended" == phase then --print( "Ended" ) end -- If the scrollView has reached it's scroll limit if event.limitReached then if "up" == direction then print( "Reached Top Limit" ) elseif "down" == direction then print( "Reached Bottom Limit" ) elseif "left" == direction then print( "Reached Left Limit" ) elseif "right" == direction then print( "Reached Right Limit" ) end end return true end -- Create a ScrollView local scrollView = widget.newScrollView { left = 0, top = 0, width = display.contentWidth, height = display.contentHeight, bottomPadding = 0, id = "onBottom", horizontalScrollDisabled = false, verticalScrollDisabled = true, listener = scrollListener, } --Create a Rectangle local myRectangle1 = display.newRect( 50, 420, 50, 50 ) myRectangle1:setFillColor( 1, 0.2, 0.2 ) local myRectangle2 = display.newRect( 120, 420, 50, 50 ) myRectangle2:setFillColor( 1, 0.2, 0.2 ) local myRectangle3 = display.newRect( 190, 420, 50, 50 ) myRectangle3:setFillColor( 1, 0.2, 0.2 ) local myRectangle4 = display.newRect( 260, 420, 50, 50 ) myRectangle4:setFillColor( 1, 0.2, 0.2 ) local myRectangle5 = display.newRect( 330, 420, 50, 50 ) myRectangle5:setFillColor( 1, 0.2, 0.2 ) local myRectangle6 = display.newRect( 400, 420, 50, 50 ) myRectangle6:setFillColor( 1, 0.2, 0.2 ) local myRectangle7 = display.newRect( 470, 420, 50, 50 ) myRectangle7:setFillColor( 1, 0.2, 0.2 ) local myRectangle8 = display.newRect( 540, 420, 50, 50 ) myRectangle8:setFillColor( 1, 0.2, 0.2 ) local myRectangle9 = display.newRect( 610, 420, 50, 50 ) myRectangle9:setFillColor( 1, 0.2, 0.2 ) scrollView:insert( myRectangle1 ) scrollView:insert( myRectangle2 ) scrollView:insert( myRectangle3 ) scrollView:insert( myRectangle4 ) scrollView:insert( myRectangle5 ) scrollView:insert( myRectangle6 ) scrollView:insert( myRectangle7 ) scrollView:insert( myRectangle8 ) scrollView:insert( myRectangle9 )

Thank you

Hi @contact36,

I’m not sure what you mean by “out of the device screen”. If you’re putting these in a scrollView, do you want to be able to scroll left and right so you can “reach” all rectangles? Or do you want all of them to appear on the screen? If so, then what is the purpose of the scrollView?

Brent

Hi @contact36,

I’m not sure what you mean by “out of the device screen”. If you’re putting these in a scrollView, do you want to be able to scroll left and right so you can “reach” all rectangles? Or do you want all of them to appear on the screen? If so, then what is the purpose of the scrollView?

Brent