2011-07-12 46 views
0

我想在我的Blackberry app中创建一个MainScreen类型的应该是Transparen/Translucent。 我用下面的代码试图在MyCustomMainScreen's构造函数,但它仍然显示一个白色的屏幕在黑莓中创建透明主屏幕

Background bg = BackgroundFactory.createSolidTransparentBackground(Color.BLACK, 50); 
this.setBackground(bg); 

我在论坛上阅读,也测试了它的弹出屏幕和它正常工作与他们,但失败mainscreens。 有没有人有任何想法如何实现这个MainScreen ..?

- 大Ø

回答

3

覆盖paint方法,如:

class M extends MainScreen 
{ 
     public M() 
     { 
      setBackground(BackgroundFactory.createSolidTransparentBackground(Color.ANTIQUEWHITE, 100)); 
      LabelField l=new LabelField("hello"); 
      add(l); 
     } 
     protected void paint(Graphics graphics) 
     { 
      super.subpaint(graphics); 
     } 
    } 
+0

感谢维韦克这是真正有用的,但是当我加入3个HorzontalFieldManagers(HFMs),每一个在圈有aBitMapField,以屏幕和滚动它,BitmapField图像留下痕迹,看起来不好。任何想法如何处理..? –

+0

在HorzontalFieldManager的paint()方法中使用invalidate()方法。 –

+0

Vivek,我试图在HFM的paint()方法中调用invalidate()来阻止我的BitMapFields,但是之后它甚至不会滚动。看起来像一个循环,只要它从paint()方法绘制并调用invalidate()方法,这会导致它再次依次调用paint()。 –

1

而不是

Background bg = BackgroundFactory.createSolidTransparentBackground(Color.BLACK, 50); 
this.setBackground(bg); 

也许更好

Background bg = BackgroundFactory.createSolidTransparentBackground(Color.BLACK, 50); 
getMainManager().setBackground(bg); 
+0

而不重写paint()方法。 getMainManager()的setBackground(BG);不工作。 –

1

我发现没有重写解决方案方法。您需要设置背景全透明屏幕和半透明的主要经理:

// Full transparent background 
setBackground(BackgroundFactory.createSolidTransparentBackground(0, 0)); 

// Manager translucent background 
getMainManager().setBackground(BackgroundFactory.createSolidTransparentBackground(Color.BLACK, 50));