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
New Developer
dojasam
Posts: 23
Registered: ‎11-24-2008
My Device: Not Specified

vertically align components

Hello everybody!

it is possible to vertically align components on a Screen ?

I use VerticalFieldManager but it does'nt seem to work :smileysad:

However, HorizontalFieldManager works perfectly if you want to align horinzontally.

 

Thank you for your Help!

 

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: vertically align components

MainScreen does contain a VerticalFieldManager per default, all fields you add using the add method are displayed in a vertical layout.
Can you show us your code?
----------------------------------------------------------
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
Please use plain text.
New Developer
dojasam
Posts: 23
Registered: ‎11-24-2008
My Device: Not Specified

Re: vertically align components

[ Edited ]

Hello,

 

i have a method to add component. so i want to align (or center) all theses component verticatly with a VerticalFieldManager on my MainScreen.

Thank you.

 

 

public class TestScreenVertical extends MainScreen{

 

VerticalFieldManager vfm;

BitmapField headerField

ButtonField button1;

ButtonField button2;

 

public  TestScreenVertical(){

button1=new ButtonField("button1");

button2=new ButtonField("button2");

header = Bitmap.getBitmapResource("head_center.png");

headerField =  new BitmapField(header, Field.FIELD_HCENTER);

addOnScreen(headerField , true);

addOnScreen(button1, true);

addOnScreen(button2, true);

add(vfm);

}

 

 

 

private void addOnScreen(Field field, boolean alignVertical) {

        if (alignVertical) {
            
            if (vfm == null) {
                vfm = new VerticalFieldManager(VerticalFieldManager.FIELD_VCENTER);
            }
            
            vfm.add(field);
            
            
        } else {
            add(field);
        }

    }

 

}

Message Edited by dojasam on 01-20-2009 07:57 AM
Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: vertically align components

The screen already has a verticalfieldmanager, you can just call add.
your code does not look very failsafe. for example, if you call your addOnScreen with false only you will get an exception on add(vfm) as it is still null.
you will also have a different order of fields depending on you adding them to the screen or your vfm.

What do you want to achieve with your code? I am pretty sure there is a more simple and elegant way to solve your problem.
----------------------------------------------------------
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
Please use plain text.
New Developer
dojasam
Posts: 23
Registered: ‎11-24-2008
My Device: Not Specified

Re: vertically align components

i agree with you. i quickly just put a part of my source code :smileyhappy:

I just want to center my elements vertically. it is possible?

Than.

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: vertically align components

by center vertically you mean that there is some free space, then there are your fields and then there is free space again?
I don't think this can be achieved by a style set for VerticalFieldManager.
You could use a spacerfield (take a NullField and overwrite its height), position your fields directly or use a special 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
Please use plain text.
New Developer
dojasam
Posts: 23
Registered: ‎11-24-2008
My Device: Not Specified

Re: vertically align components

[ Edited ]

ok, so on blackberry device, if i understand, it's impossible to center a component on a screen, it's very incroyable..

 

Thanks for your help!

Message Edited by dojasam on 01-20-2009 09:49 AM
Please use plain text.