如何使主屏幕背景图像透明?
我有一个 MainScreen、VerticalFieldManager 和 ListField。我想将背景图像添加到主屏幕为透明。这是我的代码,背景图像位于所有其他字段的顶部。
Background bg =
BackgroundFactory.createBitmapBackground(
Bitmap.getBitmapResource(BACKGROUND_IMAGE_PATH)
);
setBackground(bg);
VerticalFieldManager verticalFieldManager = new VerticalFieldManager();
MyListField listField = new MyListField();
verticalFieldManager.add(listField);
add(verticalFieldManager);
我该如何解决这个问题?
I have a MainScreen, VerticalFieldManager and ListField. I want to add background image to MainScreen as transparent. Here is my code, and background image is on the top of all other fields.
Background bg =
BackgroundFactory.createBitmapBackground(
Bitmap.getBitmapResource(BACKGROUND_IMAGE_PATH)
);
setBackground(bg);
VerticalFieldManager verticalFieldManager = new VerticalFieldManager();
MyListField listField = new MyListField();
verticalFieldManager.add(listField);
add(verticalFieldManager);
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许我没有完全理解你的需求。但是,如果您想添加半透明叠加层,我认为应该可以通过覆盖
MainScreen.paint(Grahpics grahpics)
来实现。因此,首先您调用 super.paint(grahpics) 允许整个屏幕自行绘制(包括所有子字段)。然后,您只需使用
Grahpics.drawBitmap(int x, int y, int width, int height, Bitmap bitmap, int left, int top)
在屏幕上绘制半透明图像。Maybe I don't fully get your needs. However in case you want to add a semi-transparent overlay I think it should be possible via overriding the
MainScreen.paint(Grahpics grahpics)
.So first you call
super.paint(grahpics)
allowing the entire screen to paint itself (including all the child fields). Then you just draw your semi-transparent image over the sceen using theGrahpics.drawBitmap(int x, int y, int width, int height, Bitmap bitmap, int left, int top)
.