绘制位图作为主屏幕背景。如何拉伸图像?
我希望背景图像能够拉伸整个屏幕。我只是创建了一个 VerticalFieldManager 并修改了绘制方法。
verticalFieldManager = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH
| VerticalFieldManager.NO_HORIZONTAL_SCROLLBAR) {
public void paint(Graphics graphics) {
graphics.drawBitmap(0, 0, this.getWidth(), this.getHeight(),
backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
当我将 ListField 添加到 VerticalFieldManager 并滚动时,背景图像不会重新绘制。滚动时如何重新绘制背景?
I want the background image to stretch all screen. I simply created a VerticalFieldManager and modified paint method.
verticalFieldManager = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH
| VerticalFieldManager.NO_HORIZONTAL_SCROLLBAR) {
public void paint(Graphics graphics) {
graphics.drawBitmap(0, 0, this.getWidth(), this.getHeight(),
backgroundBitmap, 0, 0);
super.paint(graphics);
}
};
And when i add a ListField to the verticalFieldManager and scroll, background image is not repaint. How can i repaint background when scroll?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您的位图创建EncodedImage,甚至直接从资源中提取EncodedImage -
EncodedImage.getEncodedImageResource("res/bg.png")
。然后使用它来缩放它:
然后您可以在
Graphics
对象上绘制EncodedImage
:Create
EncodedImage
from yourBitmap
, or even directly extractEncodedImage
from resources -EncodedImage.getEncodedImageResource("res/bg.png")
.Then use this to scale it:
Then you may draw the
EncodedImage
on theGraphics
object: