Im experiencing a strange problem that I can’t for the life of me figure out. The code below is what I’m using in most of its entirety (save for the lorem ipsum text which is substantially longer). I am using it in a scrollview widget, and I’m splitting it up because scrollview seems incapable of handling long pieces of text without cutting it off.
When I load this up on the simulator, both xText and yText (which show height and contentHeight) both show 644 as the height. When I load it up on my Galaxy S1, it shows up as 820.
In the code below, the text is spaced out nicely, no huge gaps or anything that would stand out. On the phone, as you can imagine by the height difference, there are huge gaps between each set of text objects.
I’ve played around with the font, resolution, heights, sizes and things like that, but I have no idea what is causing this. As far as I can tell, scrollView is not causing this (I’m not sure why it would), as removing it doesn’t change anything.
Judging by the text displayed both in the simulator and on the phone, they are wrapping at the same places, nothing is out of the ordinary, just that the phone version has a huge gap of white at the bottom.
Anyone encounter anything similar or have any ideas as to what exactly is going on here?
[code]
local widget = require( “widget” )
local function scrollListener( event )
print( “ScrollView Event:”, event.type )
return true
end
local scrollView = widget.newScrollView{
top = 0, left = 0,
width = 320, height = 480,
friction = 0.1,
listener = scrollListener
}
local lotsOfText = “Lorem ipsum super long string of text…”
local text2 = lotsOfText
local text3 = text2
local text4 = text3
local text5 = text4
local textArray = {lotsOfText, text2, text3, text4, text5}
local textDArray = {}
local function hDisplay()
if xText ~= nil then
xText:removeSelf()
xText = nil
yText:removeSelf()
yText = nil
end
xText = display.newText(textDArray[1].height, 0, 0, native.systemFont, 36)
xText:setTextColor(255, 0, 0)
xText.x = 30
xText.y = 30
yText = display.newText(textDArray[1].contentHeight, 0, 0, native.systemFont, 36)
yText:setTextColor(0, 255, 0)
yText.x = 30
yText.y = 90
end
for i = 1, #textArray do
textDArray[i] = {}
textDArray[i] = display.newText(textArray[i], 0, 0, 320, 0, native.systemFont, 14)
textDArray[i]:setTextColor(0)
textDArray[i]:setReferencePoint(display.TopCenterReferencePoint)
textDArray[i].x = display.contentWidth/2
if i > 1 then
textDArray[i].y = textDArray[i-1].y + textDArray[i-1].height
else
–textDArray[i].y = titleText.y + titleText.contentHeight + 10 + textDArray[i].contentHeight/2
textDArray[i].y = 0
end
scrollView:insert(textDArray[i])
end
timer.performWithDelay(500, hDisplay, -1)
[/code] [import]uid: 67886 topic_id: 32141 reply_id: 332141[/import]