如何修复背景图像以对齐? (黑莓)

发布于 2024-11-26 18:17:08 字数 1003 浏览 0 评论 0原文

我使用了从另一个问题中找到的一些代码。我注释掉了 setPositionChild() 部分,因为我不确定要为 positionYpositionX 设置什么值。当我运行应用程序时,背景图像位于顶部,稍后添加到管理器的按钮都被推到图像的底部。

    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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由如风 2024-12-03 18:17:08

请在此提及您想要实现的目标。您的预期行为是什么?查看代码,子字段的位置应如您在运行应用程序时提到的那样。由于您要将 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文