如何修复背景图像以对齐? (黑莓)
我使用了从另一个问题中找到的一些代码。我注释掉了 setPositionChild()
部分,因为我不确定要为 positionY
和 positionX
设置什么值。当我运行应用程序时,背景图像位于顶部,稍后添加到管理器的按钮都被推到图像的底部。
Background bg = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("Background.JPG"));
Bitmap bmp = Bitmap.getBitmapResource("Background.JPG");
BitmapField imgField = new BitmapField(bmp);
// Create the field manager
VerticalFieldManager manager = new VerticalFieldManager()
{
// Overide the sublayout of the field manager to set the position of
// the image directly
/* protected void sublayout(int width, int height)
{
setPositionChild(imgField, positionX, positionY)
setExtent(width, height)
}*/
};
// Set the background of the field manager
manager.setBackground(bg);
// add the bitmap field to the field manager
manager.add(imgField);
// add the field manager to the screen
add(manager);
I used some code that I found from another question. I commented out the setPositionChild()
part because I wasn't sure what values to put for positionY
and positionX
. When I run the app, the background image is on the top and the buttons that I add to the manager later are all pushed together at the bottom of the image.
Background bg = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("Background.JPG"));
Bitmap bmp = Bitmap.getBitmapResource("Background.JPG");
BitmapField imgField = new BitmapField(bmp);
// Create the field manager
VerticalFieldManager manager = new VerticalFieldManager()
{
// Overide the sublayout of the field manager to set the position of
// the image directly
/* protected void sublayout(int width, int height)
{
setPositionChild(imgField, positionX, positionY)
setExtent(width, height)
}*/
};
// Set the background of the field manager
manager.setBackground(bg);
// add the bitmap field to the field manager
manager.add(imgField);
// add the field manager to the screen
add(manager);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请在此提及您想要实现的目标。您的预期行为是什么?查看代码,子字段的位置应如您在运行应用程序时提到的那样。由于您要将 BitmapField (imageField) 添加到管理器,然后可能将按钮(未在代码中显示,假设您将其添加到代码中的其他位置)添加到管理器。那么请提供有关您想要实现的目标的更多详细信息?
Please mention what you are trying to achieve here. What's your expected behavior? Looking at code, the child fields should be positioned as you have mentioned when you run app. Since you are adding BitmapField (imageField) to manager and then probably adding buttons(not shown in code, assuming you are adding it somewhere else in code) to the manager. So provide more details on what you want to achieve?