widget.newScrollView

Hello! I have some problem with newScrollView.

I created newScrollViwe object:

\_W = display.viewableContentWidth + -1 \* display.screenOriginX; \_H = display.viewableContentHeight + -1 \* display.screenOriginY; -- Create the widget scrollView = widget.newScrollView { top = \_H/4, left = 0, width = \_W, height = \_H/10, scrollWidth = \_W, scrollHeight = \_H, listener = scrollListener } scrollView.anchorY = 0

Next, i inserted several images:

bg = {} -- Create a image and insert it into the scroll view for i=1,2 do bg[i] = display.newImage( "paper\_bkg.png", 0, 0 ) bg[i].anchorX = 0; bg[i].anchorY = 0; bg[i].xScale = \_W/2/bg[i].contentWidth; bg[i].yScale = \_H/10/bg[i].contentHeight; bg[i].y = (i-1)\*(\_H/10+ 5); bg[i]:setFillColor(math.random(),math.random(),math.random()); print(i, bg[i].y) scrollView:insert( bg[i] ) end

Next I tried to change scrollView height(decrease/increase):

timer.performWithDelay(3000, function() transition.to(scrollView, { time=200, height = \_H/4 }) end);

If height is decreasing, than my first object moving up out of scrollView. If height is increasing, than my last object set visible out of scrollView. Any ideas?

Hi @2reckiy,

Once created, scrollViews cannot be adjusted via .height or .width, nor by scaling. If you need to make this appearance visually occur, one option is to apply a mask to the scrollView and then adjust the mask size via transition or similar.

Best regards,

Brent

Thx, Brent. I just did so.

Hi @2reckiy,

Once created, scrollViews cannot be adjusted via .height or .width, nor by scaling. If you need to make this appearance visually occur, one option is to apply a mask to the scrollView and then adjust the mask size via transition or similar.

Best regards,

Brent

Thx, Brent. I just did so.