【问题标题】:Transparent VerticalFieldManager background透明 VerticalFieldManager 背景
【发布时间】:2010-09-01 21:56:25
【问题描述】:

我的目标是在屏幕中心下方 80 像素处制作一个带有动画 gif 的初始屏幕。加载屏幕的背景图像和动画 gif 很容易,将动画 gif 定位在中心下方 80 像素处也是如此。我的问题是 VerticalFieldManager 背景(包含动画 gif 字段)填充为全白色(默认情况下)。我可以设置经理的背景颜色,但屏幕的背景图片不只是一种纯色。

public final class SplashScreen extends MainScreen {
  public SplashScreen() {
    // create and load the background image BitmapField
    this.add(backgroundImage);

    // create and load the progress bar
    BitmapField progressBar = new BitmapField(progressBarImage, Field.FIELD_HCENTER | Field.USE_ALL_WIDTH | Field.NON_FOCUSABLE);

    VerticalFieldManager manager = new VerticalFieldManager(Field.USE_ALL_WIDTH | Field.FIELD_HCENTER) {
      protected void sublayout(int maxWidth, int maxHeight) {
        // positioning code...
      }
    };

    manager.add(progressBar);
    this.setStatus(manager);
  }
}

我尝试了各种 subpaint() 覆盖来设置图形,但除了纯色之外似乎无法设置任何东西。调用 setGlobalAlpha() 也没有预期的结果(如其他帖子中所述)。

有什么想法吗?

【问题讨论】:

    标签: java blackberry


    【解决方案1】:

    您可以尝试使用paintBackground 方法来绘制所有背景图像和颜色。

    protected void paintBackground(Graphics g) {
        g.setGlobalAlpha(255);
        g.setColor(backgroundColor);
        ... more background drawing ...
    }
    

    【讨论】:

      【解决方案2】:

      要修改屏幕上的背景,请使用

      this.getMainManager().setBackground(...);
      

      您应该能够设置图像、颜色以及屏幕背景所需的任何内容。

      【讨论】:

        猜你喜欢
        • 2011-03-08
        • 2021-09-20
        • 2019-02-07
        • 2020-10-15
        • 2017-06-22
        • 2010-10-20
        • 2011-02-01
        • 2013-12-10
        • 2013-07-31
        相关资源
        最近更新 更多