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

New Contributor
Posts: 6
Registered: ‎06-19-2012
My Device: developer
My Carrier: na

Adding a background image...

[ Edited ]

I have been having problems with adding  a image at the startup main screen as background....

 the problem I was facing is placing the image correctly according to different screen resolution...


as a first solution I took the image and created the image for all available resolutions on blackberry application...


and then using Display.width() and Display.Height()...show the image accordingly..


the task was cumbersome and made my cod very large....



so after much thought I applied this idea...


took the 320*240 resolution image and


used this code


    g.drawBitmap( (Display.getWidth()/2-160) ,Display.getHeight()/2-120,Display.getWidth(),Display.getHeight(),_bitmap, 0, 0);


to place it at center of the screen ...


now the screen looks better with a logo at the center on phones with every resolution...



hope it helps

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

Re: Adding a background image...

Nice idea


To make this a little more general, you could code the following which will center any bitmap in any Field.


g.drawBitmap( (this.getWidth() - _bitmap.getWidth())/2 ,(this.getHeight() - _bitmap.getHeight())//2,_bitmap.getWidth(),_bitmap.getHeight(), _bitmap, 0, 0);