Screen Orientation problem on Android?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Screen Orientation problem on Android?
[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
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?
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.
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Screen Orientation problem on Android?
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.jacque wrote:resizeStack message ... is sent reliably after that on each rotation.
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?
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:
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:
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.
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
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
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 1
- Joined: Wed Dec 07, 2011 10:30 pm
Re: Screen Orientation problem on Android?
hmm those look correct format code below. thanks for sharing !!
Re: Screen Orientation problem on Android?
hello jacques,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.
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?
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
http://lessons.runrev.com/s/lessons/m/4 ... is-resized
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com