Java 如何修复背景图像以对齐?(黑莓手机)
我使用了从另一个问题中找到的一些代码。我注释掉了Java 如何修复背景图像以对齐?(黑莓手机),java,blackberry,background-image,Java,Blackberry,Background Image,我使用了从另一个问题中找到的一些代码。我注释掉了setPositionChild()部分,因为我不确定要为positionY和positionX设置哪些值。当我运行应用程序时,背景图像位于顶部,我稍后添加到管理器中的按钮都被推到图像底部 Background bg = BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("Background.JPG")); Bitmap bmp = Bitmap.g
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);
请在这里提及您正在努力实现的目标。你期望的行为是什么?查看代码,子字段的位置应该与您在运行应用程序时提到的位置相同。因为您将位图字段(imageField)添加到管理器中,然后可能会将按钮(假设您在代码中的其他地方添加按钮,则代码中未显示)添加到管理器中。因此,请提供更多关于您想要实现的目标的详细信息?事实上,我现在明白您的意思了。我删除了添加imageField,它按照我希望的方式工作。