Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Adding display object top the top of a scrollview
Started by richard11 Dec 10 2018 04:55 AM

No replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

richard11

[GLOBAL: userInfoPane.html]
richard11
  • Contributor

  • 464 posts
  • Corona SDK

First time using scrollviews and I it seems they don't quite work how I'd expected...

 

The following creates scrollingContent in the right place (contentAreaTop etc are calculated based on previously added elements). contentGroup is just a display group for z-ordering.

 

heightHandle though, appears to be being positioned relative to the centre of the scrollview?

 

Of course I could just manually deduct half of the width and height to compensate, but I wanted to check there isn't a more 'proper' method than that? I don't want to end up skewing the actual scroll mechanic later on when this thing has more than just a rect sitting in it...

	local scrollingContent = widget.newScrollView( { left = 0, top = contentAreaTop, width = 320, height = contentAreaHeight, horizontalScrollDisabled = true, backgroundColor = { 233 / 255, 191 / 255, 121 / 255 }, hideScrollBar = true, bottomPadding = 40 } )
	contentGroup:insert(scrollingContent)

	local heightHandle = display.newRect( scrollingContent, 160, 0, 320, 50 )
	heightHandle:setFillColor( 106 / 255, 110 / 255, 47 / 255 )
	heightHandle.anchorY = 0




[topic_controls]
[/topic_controls]