2010-03-02 5 views

Répondre

1

Vous pouvez créer votre propre classe étend BitmapField et remplacer la méthode paintBitmap().

Comme ceci:

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); 
} 

// ... 

} 

Aussi, vous pouvez remplacer drawFocus(), PaintBackground() et autres.

1

Aussi, vous pouvez dessiner le texte sur le 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)); 
    } 
} 

Autre moyen est de mettre en œuvre la mise en page personnalisée comme dans Blackberry - fields layout animation

0

Ou utilisez a negative margin (le code source est disponible en téléchargement au bas de cette page):

enter image description here

MISE À JOUR: Un lien de plus pour NegativeMarginVerticalFieldManager

+0

Lien brisé, veuillez fournir le code. –

+1

Ici, vous allez, utilisé Google pour vous. –

Questions connexes