1
下面的類是自定義標籤字段,它將一個位圖作爲背景。我重寫getprefferedwidth和getpreferredheight,這不會設置我的領域的高度和寬度?目前,寬度和高度沒有被正確設置修改LabelField的尺寸(黑莓)
感謝
public class TimerLabelField extends LabelField {
private int colour;
private Bitmap backgroundBitmap;
public TimerLabelField(Object text, long style, Font font, int colour,
Bitmap backgroundBitmap) {
super(text, style);
this.colour = colour;
this.backgroundBitmap = backgroundBitmap;
}
protected void paint(Graphics graphics) {
if(backgroundBitmap != null){
graphics.drawBitmap(0, 0, this.backgroundBitmap.getWidth(), this.backgroundBitmap.getHeight(), this.backgroundBitmap, 0, 0);
}
graphics.setColor(this.colour);
super.paint(graphics);
}
public int getPreferredWidth()
{
return this.backgroundBitmap.getWidth();
}
public int getPreferredHeight()
{
return this.backgroundBitmap.getHeight();
}