Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: Telkomsel
Accepted Solution

How to change layout orientation from topToBottom to leftToRight if screen orientation change from portrait to landscape

[ Edited ]

Hi, I want to change container layout orientation from topToBottom to leftToRight if screen orientation change from portrait to landscape.

 

How to do that?

 

I'm already use this 

on QML

 

attachedObjects: [
   OrientationHandler {
   onOrientationAboutToChange: {
      if (orientation == UIOrientation.Landscape) {
         myContainer.layout = ....  // want to change to leftToRight
      } else {
         myContainer.layout = .... // want to change to topToBottom
      }
   }
}
]

 

I don't know how to set new value

 

Thanks

Contributor
Posts: 36
Registered: ‎06-28-2012
My Device: BB10
My Carrier: RIM

Re: How to change layout orientation from topToBottom to leftToRight if screen orientation change from portrait to landscape

[ Edited ]

Hi,

 

Use this below code :

 

attachedObjects: [
   OrientationHandler {
   onOrientationAboutToChange: {
      if (orientation == UIOrientation.Landscape) {
         myContainer.layout.orientation = LayoutOrientation.LeftToRight    // For landscape
      } else {
         myContainer.layout.orientation = LayoutOrientation.TopToBottom  // For portrait
      }
   }
}
]

 

Thanks

Developer
Posts: 237
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: Telkomsel

Re: How to change layout orientation from topToBottom to leftToRight if screen orientation change from portrait to landscape

Thanks it works

Developer
Posts: 1,650
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: How to change layout orientation from topToBottom to leftToRight if screen orientation change from portrait to landscape

one tip:

 

seems that you at default have designed in Portrait (top-down)

if the user starts in Landscape, then there's no event that the orientation changed.

so it's a good practice to add some code while Page was constructed:

 

onCreationCompleted: {
    if (OrientationSupport.orientation == UIOrientation.Landscape) {
        // do landscape stuff
    } 
}

then it will work always

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner