如何在BlackBerry屏幕上设置图像边框
我在BB屏幕上有一个列表项(图像和文本), 我的要求是为BB屏幕上的图像设置一个图像边框(以便对列表项进行图像分离) 有人能帮忙吗 这是我的代码:如何在BlackBerry屏幕上设置图像边框,blackberry,java-me,Blackberry,Java Me,我在BB屏幕上有一个列表项(图像和文本), 我的要求是为BB屏幕上的图像设置一个图像边框(以便对列表项进行图像分离) 有人能帮忙吗 这是我的代码: public void drawListRow(ListField list, Graphics g, int index, int y, int width) { String title = (String) listElements.elementAt(index); Bitmap im
public void drawListRow(ListField list, Graphics g, int index, int y,
int width) {
String title = (String) listElements.elementAt(index);
Bitmap image = (Bitmap) listImage.elementAt(index);
int LEFT_OFFSET = 2;
int TOP_OFFSET = 8;
int xpos = LEFT_OFFSET;
int ypos = TOP_OFFSET + y;
int w = image.getWidth();
int h = image.getHeight();
g.drawBitmap(xpos, ypos, w, h, image, 4, 6);
xpos = w + 20;
g.setFont(myFont);
g.setColor(Color.BLACK);
g.drawText(title, xpos, ypos);
}
我希望我正确地回答了您的问题,并建议您在图像周围画一个矩形,如下所示:
g.setColor(Color.RED);
g.drawRect(xpos - 1, ypos - 1, w + 1, h + 1);
这将在图像周围绘制矩形,而不会重叠。有关为什么需要调整矩形位置和大小的更多详细信息,请查看此处的Graphics class文档您需要哪些帮助?看起来您已经有了可用的绘制代码-只需更改x、y位置,即可为位图添加更多边框。@MichaelDonohue谢谢。。。。