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
guillemmat
Posts: 15
Registered: ‎10-13-2010
My Device: 9900
My Carrier: Vodafone

Custom field height to use all screen

Hello all,

 

I'm extending Field to create my customfield which is intenteded to show an image using all the screen available space. With that i mean that i'm looking to get my field use all available height and width, so if i have a title bar, it should use the screen height minus the title bar.

 

The problem is i don't know how to exactly accomplish that. I guess it has something to do with setextent and layout, but i don't know if there is some way the get the available screen height and width on the field itself or i have to pass them from the manager (which would not be my preferred solution).

 

Thanks!

 

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Custom field height to use all screen

You can use Display.getHeight() and Display.getWidth() to determine the amount of available real estate on the screen.

 

You'll then want to override getPreferredHeight() and getPreferredWidth() in your Field implementation.

 

 

 

Please use plain text.
Contributor
guillemmat
Posts: 15
Registered: ‎10-13-2010
My Device: 9900
My Carrier: Vodafone

Re: Custom field height to use all screen

But if i'm not mistaken Display.getHeight() and Display.getWidth() return the total size of the screen and not the available one. So if i have a title bar of 30px height and i call Display.getHeight() on a 360px height screen, Display.getHeight() will not return 330px, will return 360px, so my field will be bigger than available space on the screen. I am right or Display.getHeight() will return a different size inside a field?

 

Any other ideas?

 

Thanks

Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Custom field height to use all screen

Hi @guillemmat

 

Try the following:

 

1. Let your field extend Vertical Field Manager.

 

2. Pass USE_ALL_WIDTH & USE_ALL_HEIGHT in the call to the super in the constructor.

 

3. Set the image as a background:

setBackground(BackgroundFactory.createBitmapBackground(bitmap, Background.POSITION_X_LEFT, Background.POSITION_Y_TOP, Background.REPEAT_SCALE_TO_FIT);

 

Hope that helps,

 

E.

Please use plain text.