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: 27
Registered: ‎02-20-2013
My Device: 9900
My Carrier: Telkomsel
Accepted Solution

adding fix size backgorund to field manager

hello, i want to resize my backgorund image to fit into field manager and then used it  as a background.

here is my code

 

HorizontalFieldManager titleMngr = new HorizontalFieldManager();
LabelField labelLogin = new LabelField("Device Activaiton");
Bitmap panelTopBGBitmap = Bitmap.getBitmapResource("_background.png"); Bitmap panelTopBGResBitmap = GPATools.ResizeTransparentBitmap(panelTopBGBitmap, titleMngr.getPreferredWidth(), titleMngr.getPreferredHeight(), Bitmap.FILTER_LANCZOS, Bitmap.SCALE_STRETCH); Background panelTopBG = BackgroundFactory.createBitmapBackground(panelTopBGResBitmap,0,0,Background.REPEAT_NONE); titleMngr.setBackground(panelTopBG);
titleMngr.add(labelLogin); add(titleMngr);

 titleMngr.getPreferredHeight() and titleMngr.getPreferredWidth() always return me value 0.

how do i get the exact size of titleMngr? please

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

Re: adding fix size backgorund to field manager

the size of the title manager is only known after layout.
you could try to add the labelfield and check if the preferred values return something meaningful then, otherwise you could ask the labelfield directly.
----------------------------------------------------------
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
Contributor
Posts: 27
Registered: ‎02-20-2013
My Device: 9900
My Carrier: Telkomsel

Re: adding fix size backgorund to field manager

how to do that on my code above?

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

Re: adding fix size backgorund to field manager

move titleMngr.add(labelLogin); directly below the labelfield constructor.
check if you still get 0 from the manager.
----------------------------------------------------------
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
Highlighted
Contributor
Posts: 27
Registered: ‎02-20-2013
My Device: 9900
My Carrier: Telkomsel

Re: adding fix size backgorund to field manager

outchh.. thank you very much