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

Java Development

Reply
New Developer
Posts: 46
Registered: ‎12-16-2013
My Device: 9780 Bold
My Carrier: Airtel

Device Orientation - UI is not fixing to the screen

screencap_1393203652983.pngscreencap_1393203662586.png

 

 

Above screen shot (1) device in portrait mode top header is fixed to the screen. But in screen shot(2) Landscape mode top header is not fixing to the screen. 

 

Sample code what i am using to get the top header is:

 

 

GridFieldManager topheader;

topheader = new GridFieldManager(3, 3,
GridFieldManager.USE_ALL_WIDTH){

};

topheader.setRowProperty(0, GridFieldManager.FIXED_SIZE, 100);

topheader.setMargin(0, 0, 0, 0);

topheader.setBackground(BackgroundFactory
.createSolidBackground(0x312C26));

((GridFieldManager) topheader).setColumnProperty(0,
GridFieldManager.FIXED_SIZE, Display.getWidth() / 3);
((GridFieldManager) topheader).setColumnProperty(1,
GridFieldManager.FIXED_SIZE, Display.getWidth() / 3);
((GridFieldManager) topheader).setColumnProperty(2,
GridFieldManager.FIXED_SIZE, Display.getWidth() / 3);

BitmapField logoleft = new BitmapField(
Bitmap.getBitmapResource("timg.png"), DrawStyle.LEFT | Field.FOCUSABLE);
logoleft.setPadding(10, 0, 0, 10);

topheader.add(logoleft);
LabelField lblheadertxt = new LabelField("Sample", LabelField.USE_ALL_WIDTH
| LabelField.HCENTER);

topheader.add(lblheadertxt);
BitmapField logoright = new BitmapField(
Bitmap.getBitmapResource("img.png"), DrawStyle.RIGHT | Field.FOCUSABLE);
logoright.setPadding(0, 10, 0, 10);

topheader.add(logoright);

 

Can any one please tel me what am doing wrong????

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Device Orientation - UI is not fixing to the screen

could you explain what you mean with "fixing to the screen"?

regarding your code: Display.getWidth is a value that changes when the device orientation is altered. if you do not adjust your values onOrientationChange your layout logic may be faulty.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Device Orientation - UI is not fixing to the screen

The images seem to show your header at the top of the screen.  Can you explain again what is wrong with the landscape mode header?  Perhaps compare an image of what you currently see with an image of what you would like and point out the differences?

New Developer
Posts: 46
Registered: ‎12-16-2013
My Device: 9780 Bold
My Carrier: Airtel

Re: Device Orientation - UI is not fixing to the screen

I want to set the top header width to screen width in Landscape mode. 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Device Orientation - UI is not fixing to the screen

[ Edited ]

So it is the width that is the problem, not as you originally said "header is not fixing to the screen".  Next time please be more accurate....

 

When the screen orientation is changed, the sublayout() for the GridFieldManager is invoked, and in there, you could reset the width of your columns. 

 

However my recommendation would be to create your own Manager which is specific to this Header, and have it create the column widths you want.  This is more work in the short term, but will help you understand what is going on better (and you won't suffer from the vagaries of GridFieldManager which has done some weird things to me in the past).

 

You could look at this KB:

http://supportforums.blackberry.com/t5/Java-Development/Create-a-rich-UI-layout-with-TableLayoutMana...

 

as an example of a Manager that you could base your new one on, and in addition look at these two articles:

 

http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/...

 

http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749