Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 81
Registered: ‎06-24-2009
My Device: Not Specified

Transparent screen...again!?

Hello,

I'm trying to make a transparent Screen (over one of my Screens).
I've gone through all the related posts and have been experimenting with the following code.

No matter what comination of methods I try, I still don't get full transparency. The grey is
lighter but still opaque.

 

I'm testing on 8900 sim. I'm like to be compatible to 4.2.

 

What am I doing wrong?

 

Thanks!

 

 

class DialogTest extends Screen {
    
    private final static int _CUSTOM_WIDTH   = 300;
    private final static int _CUSTOM_HEIGHT   = 200;
    private final static int _ALPHA         = 0xBF; // 75% alpha
    private final static int _X             = (Display.getWidth() - _CUSTOM_WIDTH) >> 1;
    private final static int _Y             = (Display.getHeight() - _CUSTOM_HEIGHT) >> 1; 
    
    
    DialogTest() {    
        super(new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR));
        add(new LabelField("Test test test"));
    }
    
    protected void sublayout(int width, int height) {
        setExtent(_CUSTOM_WIDTH, _CUSTOM_HEIGHT);
        setPosition(_X, _Y);
        layoutDelegate(_CUSTOM_WIDTH, _CUSTOM_HEIGHT);
    }
    
    /*protected void paintBackground(Graphics graphics) {

	   XYRect myExtent = getExtent();
	   int alpha = graphics.getGlobalAlpha();
	   int color = graphics.getColor();
	   graphics.setGlobalAlpha(_ALPHA);
	   graphics.setColor(0x666666);
	   graphics.fillRoundRect(0, 0, myExtent.width, myExtent.height, 20, 20);
	   graphics.setGlobalAlpha(alpha);
	   graphics.setColor(color);

    }*/
    
    protected void paint(Graphics graphics) {

	   XYRect myExtent = getExtent();
	   int alpha = graphics.getGlobalAlpha();
	   int color = graphics.getColor();
	   graphics.setGlobalAlpha(_ALPHA);
	   graphics.setColor(0x666666);
	   graphics.fillRoundRect(0, 0, myExtent.width, myExtent.height, 20, 20);
	   graphics.setGlobalAlpha(alpha);
	   graphics.setColor(color);
	   super.paint(graphics);
                  
        
    }
    
    protected boolean keyDown(int keycode, int status) {
        if (Keypad.key(keycode) == Keypad.KEY_ESCAPE) {
            close();
            return true;
        }
        return super.keyDown(keycode, status);
    }
}

 

 

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Transparent screen...again!?

screens always have a white background. you have to use popupscreens to achieve full transparency.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 9
Registered: ‎11-19-2009
My Device: Not Specified

Re: Transparent screen...again!?

as long as i know 8900 using OS 4.6

and here is the new class to implements that

 

BackgroundFactory.createSolidTransparentBackground(color, alpha)

 

i also had same problem, so i compile it for each OS version

Developer
Posts: 81
Registered: ‎06-24-2009
My Device: Not Specified

Re: Transparent screen...again!?

simon:

 

OK. That's good to know. I have the transparency working now but with the needed empty

applyTheme override (to remove PopupScreen's border decoration), I lost my transparency.

 

What is the trick to get it back?

 

husainahmad:

 

Thanks for the suggestion. I'm trying to keep a 4.2 target.

New Developer
Posts: 2
Registered: ‎10-26-2009
My Device: Not Specified

Re: Transparent screen...again!?

Hi tkroll,

 

Did you get transparency working with removed Popupscreen's border decoration?

 

Any help much appreciated.

 

Thanks

Y

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Transparent screen...again!?

the border is controlled by the current theme.

 

You should be able to defeat the border by oeverriding applyTheme() in your PopupScreen implementation.

 

 

New Developer
Posts: 2
Registered: ‎10-26-2009
My Device: Not Specified

Re: Transparent screen...again!?

Thank you for your response RexDoug,

 

By overriding current theme

 

 

    protected void applyTheme()
    {
    }

 

 

i lose the slight transparency that popupScreen by default features. Any ideas on how i  can get a popup screen with transparent background?

 

Thanks

Y

Highlighted
Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Transparent screen...again!?

You can take a screenshot of the active screen when you push your new screen that needs the transparent background. Use that screenshot as the background for your new screen. Search the forums for an easy way to take a screenshot without asking the user for permissions (only works for your own screens since you need to override paint).

Contributor
Posts: 17
Registered: ‎08-20-2010
My Device: 9700
My Carrier: Orange - London

Re: Transparent screen...again!?

Hi, what is the value that you pass for 

Background background = BackgroundFactory.createSolidTransparentBackground(int, int); to achieve transparency?

 

Bhuvana

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Transparent screen...again!?

please open a new thread for an own question @bhuvana
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter