Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Images In A Scrollview Not Centering
Started by kbradford Mar 17 2013 01:07 PM

2 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

kbradford

[GLOBAL: userInfoPane.html]
kbradford
  • Contributor

  • 273 posts
  • Corona SDK

I'm having trouble getting images to center in the new scrollview widget.  They are close, but slightly off center.  This is in build 1054.  I attached the code, and also a screenshot of what's happening.  You can tell the red bar is CLOSE to be centered, but slightly off.  If I remove the line where it inserts into the scrollView then it centers perfectly.  Any ideas?

 

	scrollView = widget.newScrollView
	{
		left = screenLeft,
		top = 0,
		width = screenWidth-24,
		height = screenHeight,
		scrollWidth = screenWidth-24,
		scrollHeight = 1000,
		id = "onBottom",
		horizontalScrollingDisabled = true,
		verticalScrollingDisabled = false,
		hideBackground = false,
		hideScrollBar = true,
		listener = scrollListener,
	}	
	group:insert(scrollView)

		
	local rowBG = display.newImageRect( "assets/tabbar.png", 150, 210 )
	rowBG:setReferencePoint( display.CenterReferencePoint )		
									
	rowBG.y = scrollView.y
	rowBG.x = screenMiddleX
	scrollView:insert( rowBG )	

 

 

Attached Files



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,622 posts
  • Enterprise

I see you are specifying a custom size for your scrollView but you are not providing the required mask file.  Perhaps that is the cause.  I also can't tell the value of screenLeft from your code sample.  If it has any value it would push the whole scrollView right by that many pixels which would also off center your content.



[TOPIC: post.html]
#3

kbradford

[GLOBAL: userInfoPane.html]
kbradford
  • Contributor

  • 273 posts
  • Corona SDK

Thanks for the response Rob, I set the width equal to the entire screen width and the problem is fixed.




[topic_controls]
[/topic_controls]