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
Contributor
nzqadri
Posts: 13
Registered: ‎05-09-2012
My Device: Developer

transparent image

Hi,

i am using some transparent icons but i can show its background color in icons ,

Can anyone Guide me ?

how to do the transparent images show its backgound color

 

 

Nabeel Qadri
Super Contributor
pp
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above

Re: transparent image

Hi,

 

override paint method, setBackgroundColor() and drawBitmap();

 

Regards,

pp

Contributor
nzqadri
Posts: 13
Registered: ‎05-09-2012
My Device: Developer

Re: transparent image

Dear ,

 

Can you show me anycode of these methods if you can ......

Nabeel Qadri
Super Contributor
pp
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above

Re: transparent image

Hi,
Try something like this

private int backgroundColor = -1;
private Bitmap backgroundImage = null;

public void paint(Graphics g) {
if(backgroundColor != -1){
g.setColor(backgroundColor);
g.fillRoundRect(1, 1, getPreferredWidth()-2, getPreferredHeight()-2, 5, 5);
}
if(backgroundImage != null){
g.drawBitmap(1,1,backgroundImage.getWidth() - 2,backgroundImage.getHeight() - 2,backgroundImage,0,0);
}
//text managed by api if you give super.paint(g);
//else you can manage it by using d.drawText(text, x, y);
}
Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: transparent image

Can we go back to the original question:

 

"i am using some transparent icons but i can show its background color in icons ,

Can anyone Guide me ?

how to do the transparent images show its backgound color"

 

Transparent images will oridinarily show their Background through the transparent parts, so I do not understand the question.  Can the OP please explain the quesiton again?

 

If the question is how to set the Background color, then I would look at the Background class and setBackground() method.