如何为黑莓屏幕创建固定背景?

发布于 2024-10-08 06:25:31 字数 345 浏览 3 评论 0原文

我想为屏幕创建一个背景,当屏幕滚动时该背景不会移动。我当前的代码类似于:

Bitmap bitmap = Bitmap.getBitmapResource("background.png");
setBackground(BackgroundFactory.createBitmapBackground(bgBmp));

但是,这将创建一个松散的背景,这意味着如果屏幕字段超出显示范围,当用户滚动屏幕时,背景也会移动,从而使屏幕的某些部分没有背景。我不想让背景在拉伸的部分一遍又一遍地重复。然而,我真正想要的是一个固定在显示屏上的背景,并且其余字段在其顶部滚动。您知道有什么直接或间接的方法可以做到这一点吗?

I want to create a background for a screen that will not move when the screen is scrolled. My current code is something like:

Bitmap bitmap = Bitmap.getBitmapResource("background.png");
setBackground(BackgroundFactory.createBitmapBackground(bgBmp));

However this will create a loose background, meaning that if screen fields stretch out of the display, when user scrolls the screen the background will move as well leaving some part of the screen background-less. I do not want to make the background repeat itself over and over for the stretched parts. What I do want however is a background that stays pinned to the display and the rest of the fields scroll on top of it. Do you know any direct or indirect way for doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

少年亿悲伤 2024-10-15 06:25:31

将背景添加到不滚动的管理器。添加另一个管理器来保存所有字段并允许其滚动。所以它会是这样的:

VerticalFieldManager noScroll = new VerticalFieldManager(VerticalFieldManager.USE_ALL_HEIGHT 
  | VerticalFieldManager.USE_ALL_WIDTH |  VerticalFieldManager.NO_VERTICAL_SCROLL 
  | VerticalFieldManager.NO_VERTICAL_SCROLLBAR);

VerticalFieldManager scroll = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
noScroll.add(scroll);
//Add all of your fields to scroll.

Add the background to a manager that does not scroll. Add another manager to that to hold all of your fields and allow it to scroll. So it would be something like:

VerticalFieldManager noScroll = new VerticalFieldManager(VerticalFieldManager.USE_ALL_HEIGHT 
  | VerticalFieldManager.USE_ALL_WIDTH |  VerticalFieldManager.NO_VERTICAL_SCROLL 
  | VerticalFieldManager.NO_VERTICAL_SCROLLBAR);

VerticalFieldManager scroll = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
noScroll.add(scroll);
//Add all of your fields to scroll.
樱娆 2024-10-15 06:25:31

使用以下代码设置以位图作为背景的屏幕背景。

getMainManager().setBackground(BackgroundFactory.createBitmapBackground(bitmap));

Use following code to set background of screen which have bitmap as background.

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