1
我写了下面的代码在这里的背景图像显示,但图像没有覆盖整个背景如何设置背景图片fitable在黑莓应用
private Bitmap background;
int mWidth = Display.getWidth();
int mHeight = Display.getHeight();
public MyScreen()
{
// Set the displayed title of the screen
//backgroundBitmap = Bitmap.getBitmapResource("slidimage.png");
final Bitmap background = Bitmap.getBitmapResource("slidimage.png");
HorizontalFieldManager vfm = new HorizontalFieldManager(USE_ALL_HEIGHT | USE_ALL_WIDTH) {
public void paint(Graphics g) {
g.drawBitmap(0, 0,mWidth, mHeight, background, 0, 0);
super.paint(g);
}
};
add(vfm);
需要拉伸前按比例绘制(拉伸)位图。检查这个答案,http://stackoverflow.com/a/2268027/431639。 '公共静态位图resizeImage()'将解决你的问题。另请阅读API文档http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/Bitmap.html#scaleInto%28net.rim.device.api.system。位图,%20int%29。 – Rupak