[Resolved] Android Text not positioning the same as iOS

I’ve created my first app for the iPhone, and all has gone well. I’m just starting to look into Android, and I’ve noticed something weird. All of the text In my app starts lower than in my iPhone version. The coordinates are 0 so I’m not sure why this is happening.

Example:

title = display.newText( “This is a test.”, 0, 0, 320, 500, native.systemFont, 16 )
This looks great on the iPhone, showing up exactly in the upper left hand corner.

On the various Android models in the simulator, the text starts all over the place in regards to height. Shouldn’t 0 mean 0 on both operating systems?

[import]uid: 115085 topic_id: 26275 reply_id: 326275[/import]

Hey Niles,

Are you using the default font or custom? The default font is different between iOS and Android so the height will vary. (Using a custom font could be useful to fix that.

Peach :slight_smile: [import]uid: 52491 topic_id: 26275 reply_id: 106845[/import]

Hey Peach,

I’m just using the system font. And the lines and the text are spaced fine in the paragraph, it’s just that the paragraph starts much lower on the various android screens in the simulator. That’s what I don’t get. Shouldn’t “0” be “0”?
Niles [import]uid: 115085 topic_id: 26275 reply_id: 106850[/import]

OK so you are referring the y coordinate and NOT the height of the font/text, correct?

If so, what build are you currently using? [import]uid: 52491 topic_id: 26275 reply_id: 106947[/import]

Yup!

782, but I tried the latest build and it’s doing it on that as well!
Just paste this line in…do you get the same thing once you switch to Android in the simulator?
title = display.newText( “This is a test.”, 0, 0, 320, 500, native.systemFont, 16 )

Niles [import]uid: 115085 topic_id: 26275 reply_id: 106958[/import]

OK, I have a theory.

In config.lua are you using scaling? Letterbox scaling?

Try this;
[lua]bg = display.newRect( 0, 0, 320, 480 )
bg:setFillColor(255,0,0)

title = display.newText( “This is a test.”, 0, 0, 320, 500, native.systemFont, 16 )[/lua]

Is the text in the top left corner of the background there? Or is it still off?

If it appears at the top left of the background then this is a scaling issue because you have a black bar at the top and bottom due to the different aspect ratio.

Let me know :slight_smile:

Peach [import]uid: 52491 topic_id: 26275 reply_id: 107099[/import]

Yup, letterbox was the culprit!

ZoomStretch seems to remedy it. Since my app is just text and vector lines, it doesn’t seem too molested by ZoomStretch at all. I’ll use it for Android phones, and letterbox for iOS, Nook, and Kindle Fire.

Thanks Peach!

Niles [import]uid: 115085 topic_id: 26275 reply_id: 107215[/import]

Yes! Haha, I thought I was onto something with that letterbox theory :wink:

Thanks for following up to confirm, glad this could get resolved :slight_smile: [import]uid: 52491 topic_id: 26275 reply_id: 107370[/import]