Developing applications for different screen sizes

BlackBerry® devices have a wide range of screen sizes, including the following:

  • 360 x 480 pixels (BlackBerry® Torch™ smartphone, BlackBerry® Storm™ smartphone)
  • 480 x 320 pixels (BlackBerry® Bold™ smartphone)
  • 240 x 260 pixels (BlackBerry® Pearl™ smartphone)

When you create your applications, you should take into consideration the different screen sizes of the devices that your application might run on. You might need to resize any bitmaps that you use to make sure that they display correctly on each screen size. You might also need to arrange fields differently for different screen sizes.

Screen sizes can be placed into two categories, high resolution and low resolution. High resolution screen sizes include screens that have a width that is greater than 320 pixels. This category includes the 360 x 480, 480 x 360, and 480 x 320 resolutions. Low resolution screen sizes include screens that have a width that is less than or equal to 320 pixels. This category includes the 240 x 320, 240 x 260, and 320 x 240 resolutions. Because of this categorization, you need to maintain only two sets of bitmaps or layouts in your application, and switch between them based on the screen size of the device that your application is running on.

To access the screen properties of the device, you can use the methods that are available in the Display class, which is included in the net.rim.device.api.system package. You can use this class to access information such as screen size, dimensions, and orientation. For example, to retrieve the width of the screen and switch bitmap sets or layouts accordingly, you can use the following code:

boolean lowRes = Display.getWidth() <= 320;

if (lowRes)
{
    // The device has a low resolution screen size
}
else
{
    // The device has a high resolution screen size
}
Previous topic: Screen classes

Was this information helpful? Send us your comments.