Page 1 of 1
Screen Orientation problem on Android?
Posted: Thu May 26, 2011 11:51 pm
by webmaster
[Posted this in the "Summer Academy" forum, but would LOVE to know what the wider audience of LiveCoders is seeing.]
Is anyone else seeing a Screen orientation problem on Android devices?
I've got some code that switches between a vertical and horizontal layout depending on the "mobileDeviceOrientation." This is triggered by the "orientationChanged" event. The code is firing on cue, and the proper horizontal or vertical screen is being displayed.
HOWEVER... when in the horizontal/landscape screen, it is displayed sideways from top to bottom of the right side of the screen. The right side of my interface is cut-off.
On the iPhone Simulator, the same code is working 100% (actually showing landscape screens horizontally).
Am I missing some setting, or is this an bug in the Android engine?
--ForrestD
Re: Screen Orientation problem on Android?
Posted: Fri May 27, 2011 7:28 pm
by jacque
The orientationChanged message is sent before the actual rotation happens, so if you resize in response to that message you will actually be resizing to the pre-oriented screenrect. After the rotation is complete, your stack will get a "resizeStack" message which will include the newly rotated screenrect in the parameters. That's the one you should respond to, as the screen coordinates will reflect the post-rotated screen size.
Edited to add: I think there's a bug on the first startup on Android, no resizeStack message is sent. It is sent reliably after that on each rotation.
Re: Screen Orientation problem on Android?
Posted: Sat May 28, 2011 9:25 pm
by webmaster
jacque wrote:resizeStack message ... is sent reliably after that on each rotation.
Jacque -- Thanks for the reply! I tried changing to the resizeStack event handler, but it doesn't ever seem to get triggered on my Android phone. (I put a simple answer box in the code for resizeStack, but it doesn't ever appear.) The "orientationChanged" message does seem to be triggered consistently, but I understand your clarification that the screen change doesn't happen until after that.
Could you post a code snippet that is working reliably with the resizeStack handler for you? I wonder if I'm doing something wrong in my code.
Re: Screen Orientation problem on Android?
Posted: Sat May 28, 2011 11:20 pm
by jacque
The ones I have are pretty long but nothing special. They are just the resizeStack handler with instructions that set the geometry of all the objects. They follow this pattern:
Code: Select all
on resizeStack x,y
get the rect of fld 1
put x into item 3 of it
put y into item 4 of it
set the rect of fld 1 to it
end resizeStack
That's an invented example but it's the general idea and should work in a 1-card stack. Maybe the answer dialog is interfering somehow, since it puts up a separate window. Try setting the color of a button or some other type of visual test.
If you have multiple cards, I usually do this in the stack script:
Code: Select all
on resizeStack x,y
send "doResize x,y" to this card
end resizeStack
And in each card, have a handler "doResize" that accepts the parameters x and y and uses them to resize the card objects. That's how the conference teaching stack was done, and "doResize" was called on preOpenCard in each card script, as well as on resizeStack.
Re: Screen Orientation problem on Android?
Posted: Mon Jan 16, 2012 4:35 am
by frankscott39
hmm those look correct format code below. thanks for sharing !!
Re: Screen Orientation problem on Android?
Posted: Tue Feb 21, 2012 10:24 am
by bangkok
jacque wrote: That's how the conference teaching stack was done, and "doResize" was called on preOpenCard in each card script, as well as on resizeStack.
hello jacques,
is it possible to download this teaching stack ?
it would be good to have a sample stack, like a framework, with some of the mobile tricks (like resizestack etc.).
Re: Screen Orientation problem on Android?
Posted: Tue Feb 21, 2012 6:58 pm
by jacque
I think the stack is available somewhere but I don't have a link. There's a lesson on the topic though, with example scripts:
http://lessons.runrev.com/s/lessons/m/4 ... is-resized