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

Java Development

Posts: 18
Registered: ‎05-17-2012
My Device: NA
My Carrier: NA

Orientation Change Glitch

I have a list of Screen instances in a stack and when ever i call the Orientation change it works perfectly fine with sublayout changing the images and screen width and height 


But due to the Orientation change there is some glitch coming in between the first Oreintation (say Portrait) and then a tilt giving second Orientation (say Landscape)


Below is the code i am using 




void sublayout(int width, intheight) {

if (Display.getOrientation() != screen_orientation) {

if (getVirtualKeyboard() != null
&& getVirtualKeyboard().getVisibility() == VirtualKeyboard.
screen_orientation = Display.getOrientation();

if(getFieldCount() != 0) {


super.sublayout(width, height);

Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Orientation Change Glitch

Well, I've been telling this to everyone who would listen for a couple of years now: there is indeed a problem of Display updating its width, height and orientation values after re-laying out the screen. It means that you will see some stale values during your layout/sublayout


Fortunately, there are some reliable values during all this process: the width and height passed to your Screen's sublayout! If you save them each time and compare the previous dimensions with the new ones during sublayout, you can detect the orientation change yourself. The code extracting the proper values from Display class should be wrapped in invokeLater to guarantee that it runs after the dust settles.

please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!