In my project I need to put a LabelField on top of a BitmapField. I have the BitmapField inside a Vertic开发者_Go百科alFieldManager. I want complete code for this problem.
My application is for BlackBerry OS 4.7.
You can create your own class extends BitmapField and override method paintBitmap().
Like this:
public class MyBitmapField extends BitmapField {
//...
protected void paintBitmap(Graphics g, int arg1, int arg2, int arg3,
int arg4, Bitmap arg5, int arg6, int arg7) {
super.paintBitmap(g, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
g.drawText("Your text", 5,5 );
}
// ...
}
Also you can override drawFocus(), paintBackground() and other.
Also you could draw text over bitmap:
class Scr extends MainScreen {
Bitmap bmp = new Bitmap(200, 100);
public Scr() {
//draw bitmap
Graphics g = new Graphics(bmp);
g.drawLine(0, 0, 199, 99);
g.drawLine(199, 0, 0, 99);
//draw text
Font f = getFont().derive(Font.PLAIN, 15);
g.drawText("hello", 0, (bmp.getHeight() - f.getHeight()) >> 1,
DrawStyle.HCENTER|DrawStyle.VCENTER);
add(new BitmapField(bmp));
}
}
Other way is to implement custom layout like in Blackberry - fields layout animation
Or use a negative margin (the source code is available for download at the bottom of that page):
UPDATE: One more link for NegativeMarginVerticalFieldManager
精彩评论