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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 33
Registered: ‎05-12-2010
My Device: none
My Carrier: none

Positioning a bitmap

Hi everyone!

 

I have a quick and probably very dumb question regarding the positioning of a bitmap as background in a screen. The relevant piece of code is the following:

 

        bg=BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("background.png"), POSITION_X_CENTER, POSITION_Y_CENTER, REPEAT_NONE);

And for some reason, Eclipse tells me that the three last parameters are incorrect (expecting int). What is the syntax then? I am using JDE 5.0.

 

Any kind of help would be appreciated, thanks!

Developer
Posts: 85
Registered: ‎05-03-2010
My Device: Not Specified

Re: Positioning a bitmap

Hi Benjen;

I'm a newbie myself but a quick search using the community search option and using the phrase "set image as background" gives this as the first result:

 

http://supportforums.blackberry.com/t5/Java-Development/Use-a-background-image-in-application-screen...

 

The article is a Knowledge Base article and is probably what you are looking for. Smiley Happy

Developer
Posts: 282
Registered: ‎02-25-2010
My Device: curve,bold,storm
My Carrier: Verizon,AT&T

Re: Positioning a bitmap

I think u can go ahead like this:

 

create a vertical field maanger and place the image in the paint method

 

VerticalFieldManager vfm = new VerticalFieldManager()
{
final Bitmap background = Bitmap.getBitmapResource("back.png")
protected void paint(Graphics g)
{
int y = this.getVerticalScroll;
g.drawBitmap(0,y,background.getwidth,background.getHeight,background,0,0)
}
protected void sublayout(int width,int height)
{
//here u can set the position of other elements that belongs to this manager
}
}
Highlighted
Contributor
Posts: 33
Registered: ‎05-12-2010
My Device: none
My Carrier: none

Re: Positioning a bitmap

[ Edited ]

Thanks for the reply, however this would not center both verticaly and horizontaly the image, would it?

 

I have read the knowledge base article of course, it is just that I don't know how to use the following function for example:

 

Background bg = BackgroundFactory.createBitmapBackground(Bitmap bitmap, int positionX, int positionY, int repeat);

 

given the following possible arguments:

 

  • positionX is the horizontal bitmap anchoring using any of the following positions:
  • POSITION_X_LEFT
  • POSITION_X_CENTER
  • POSITION_X_RIGHT
  • positionY is the vertical bitmap anchoring using any of the following positions:
  • POSITION_Y_LEFT
  • POSITION_Y_CENTER
  • POSITION_Y_RIGHT
  • repeat is the tiling option that can be any following values:
  • REPEAT_NONE
  • REPEAT_HORIZONTAL
  • REPEAT_VERTICAL
  • REPEAT_BOTH
  • REPEAT_SCALE_TO_FIT

  • Eclipse does not reckognize them as int, how should I use them?

    Thanks again!