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
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!