私はカスタムフィールドの背景としてBitmap
を描画しますが、フィールド全体の領域にビットマップを描画しません。私もイメージのサイズを変更しましたが、それは常に右と下にいくつかのスペースを残します。これは、次のようになります。BlackberryカスタムフィールドdrawBitmapはスペース全体を使用しません
ここでは塗装のためのいくつかのコードです:
public int getPreferredWidth(){
return phoneWidth;
}
public int getPreferredHeight(){
return cellHeight;
}
protected void paint(Graphics g) {
Bitmap img = Bitmap.getBitmapResource("cell_bg.png");
img.scaleInto(new Bitmap(phoneWidth, cellHeight), Bitmap.SCALE_TO_FIT);//or other scaling methods
g.drawBitmap(0, 0, phoneWidth, cellHeight, img, 0, 0);//draw background
//other steps
}
私はfollows-
Background bg = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("cell_bg.png"),0,0,Background.REPEAT_SCALE_TO_FIT);
this.setBackground(bg);
が、この方法としてBackground
を設定した場合、それは正常に動作します、背景画像は表示されませんonFocus
。
私はここで間違っていますか?
Display.getHeight()とDisplay.getWidth()メソッドでデバイスの高さと幅を取ろうとしました。 –
変数 'phoneWidth'は' Display.getWidth() 'として計算されましたので問題はありません – tipycalFlow