开发者

Transparent VerticalFieldManager background

开发者 https://www.devze.com 2023-01-12 13:45 出处:网络
My goal is to have a splash screen with an animated gif 80 pixels below center of the screen.Loading the screen\'s开发者_高级运维 background image and animated gif is easy, as is positioning the anima

My goal is to have a splash screen with an animated gif 80 pixels below center of the screen. Loading the screen's开发者_高级运维 background image and animated gif is easy, as is positioning the animated gif 80px below center. My problem is that the VerticalFieldManager background (which contains the animated gif field) is filled with all white (by default). I can set the manager's background color, but the screen's background image isn't just one solid color.

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);
  }
}

I've tried various subpaint() overrides to set the Graphics, but can't seem to set anything other than a solid color. Calling setGlobalAlpha() doesn't have the desired results either (as noted in other posts).

Any thoughts?


You may try using the paintBackground method to paint all of your background images and colors.

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


For modifying the background on screens, use

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

You should be able to set and image, a color, whatever you need for the background to the screen.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号