Fit the image to the screen in blackberry
How can i fit a large image o开发者_StackOverflow社区n a BlackBerry simulator so that the whole image appears without getting cropped?Can anyboby help me with a code example
There are many ways you could do this but if it fits with your requirements then the backgroundfactory is nice. http://www.blackberry.com/developers/docs/4.6.0api/net/rim/device/api/ui/decor/BackgroundFactory.html
// specify the bitmap and xy positioning to meet your needs
Background background = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("bitmap.png"),Background.POSITION_X_LEFT, Background.POSITION_Y_BOTTOM, Background.REPEAT_NONE);
// create a field manager and set its BG to this one
VerticalFieldManager body = new VerticalFieldManager(USE_ALL_WIDTH|USE_ALL_HEIGHT);
body.setBackground(background);
add(body);
//Some other options
//Background.REPEAT_NONE
//Background.REPEAT_SCALE_TO_FIT
//Background.REPEAT_VERTICAL
//Background.REPEAT_HORIZONTAL
精彩评论