Create Transparent Mainscreen in Blackberry

不问归期 提交于 2019-12-13 06:21:36

问题


i want to create a type of MainScreen in my Blackberry app which should be Transparen/Translucent. I tried with following code on MyCustomMainScreen's constructor but it still shows a white screen

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

I have read in the forum and also tested it for popup screens and it works fine with them but fails with mainscreens. Does anyone have any idea how to achieve this for MainScreen..?

-Big O


回答1:


override the paint method like:

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



回答2:


Instead of

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

maybe better

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



回答3:


I found the solution without overriding the paint method. You need to set the background full transparent for the Screen and translucent for the main manager:

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

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


来源:https://stackoverflow.com/questions/6659649/create-transparent-mainscreen-in-blackberry

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!