Screen Orientation problem on Android?

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
webmaster
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 81
Joined: Mon May 09, 2011 3:01 pm

Screen Orientation problem on Android?

Post by webmaster » Thu May 26, 2011 11:51 pm

[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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Screen Orientation problem on Android?

Post by jacque » Fri May 27, 2011 7:28 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

webmaster
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 81
Joined: Mon May 09, 2011 3:01 pm

Re: Screen Orientation problem on Android?

Post by webmaster » Sat May 28, 2011 9:25 pm

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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Screen Orientation problem on Android?

Post by jacque » Sat May 28, 2011 11:20 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

frankscott39
Posts: 1
Joined: Wed Dec 07, 2011 10:30 pm

Re: Screen Orientation problem on Android?

Post by frankscott39 » Mon Jan 16, 2012 4:35 am

hmm those look correct format code below. thanks for sharing !!

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Screen Orientation problem on Android?

Post by bangkok » Tue Feb 21, 2012 10:24 am

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.).

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Screen Orientation problem on Android?

Post by jacque » Tue Feb 21, 2012 6:58 pm

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
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply