在我的项目中,我需要将一个LabelField放在BitmapField的顶部。我在VerticalFieldManager中有BitmapField。我想要完整的代码来解决这个问题。使用BlackBerry中的另一个UI字段重叠UI字段
我的应用程序是为BlackBerry OS 4.7。
在我的项目中,我需要将一个LabelField放在BitmapField的顶部。我在VerticalFieldManager中有BitmapField。我想要完整的代码来解决这个问题。使用BlackBerry中的另一个UI字段重叠UI字段
我的应用程序是为BlackBerry OS 4.7。
您可以创建自己的类扩展BitmapField并覆盖方法paintBitmap()。
像这样:
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);
}
// ...
}
你也可以覆盖DRAWFOCUS(),paintBackground()等。
你也可以绘制文本了位图:
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));
}
}
另一种方式是实现自定义布局就像Blackberry - fields layout animation
或者使用a negative margin(源代码是可以免费下载该网页的底部):
UPDATE:另一个链接NegativeMarginVerticalFieldManager
Broken Link,请提供代码。 – 2013-02-09 20:40:27
在这里,您可以使用Google。 – 2013-02-10 08:52:18