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: 66
Registered: ‎08-21-2009
My Device: Not Specified

How to avoid screen resizing when virtual keyboard launched



We are developing an application having screen with image in background and edit box. As soon as this screen displays, virtual keyboard gets launched (as default focus is on the edit box) and screen size gets changed due to which image in the background also gets shrinks (image gets disturbed).   


Is there any work around or way to avoid screen sizing when virtual keyboard gets launched.


- Krmlkr

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

Re: How to avoid screen resizing when virtual keyboard launched

I presume you are using Display.getHeight() and Display.getWidth().


I recommend that you get these once, at application startup, and use this value where you need assets like images sized to the actual screen size. 


You may need to be careful if you are supporting the application tilting the screen, as the width becomes the height and vice versa. 


As I understand it, Display.getHeight() and Display.getWidth() are actually 'expensive' in terms of the resources required so doing this once is good practice.


If this doesn't help, look at how you are using sublayout in the Manager that you use to 'size' the background bitmap. 


Finally if you are resizing things like this, I recommend that you do it once at application start-up (say while your splash screen is displaying) and save the images.  This reduces the number of times you do this and may well reduce memory footprint, since images, especially background images, can be very large.