2010-03-02 66 views

回答

1

您可以创建自己的类扩展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()等。

1

你也可以绘制文本了位图:

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

0

或者使用a negative margin(源代码是可以免费下载该网页的底部):

enter image description here

UPDATE:另一个链接NegativeMarginVerticalFieldManager

+0

Broken Link,请提供代码。 – 2013-02-09 20:40:27

+1

在这里,您可以使用Google。 – 2013-02-10 08:52:18

相关问题