SentineL
SentineL

Reputation: 4732

How can I vertically center a title on Blackberry?

I'm trying to make a design like at the picture: requaered design

as you can see, at the top bar of the screen there is a title at the center. I can set it to horizontal center, but how to set it to vertical center?

I allready tryed:

How to set text or any other field at vertical center?

Upvotes: 0

Views: 522

Answers (1)

Kiran Kuppa
Kiran Kuppa

Reputation: 1457

The issue that you will need to solve is "How does a Manager centre vertically and Horizontally any field that is added to it". Trying to solve this problem for N number of fields added to Manager might be a bit involved but just for one field, it must be quite easy. I suggest you try this :

 VerticalFieldManager vfm = new VerticalFieldManager(){
        public void sublayout( int maxWidth, int maxHeight )
        {
            int margin = 0;
            int lheight = 0;
            Field f = getField( 0 );
            margin = f.getMarginBottom()+f.getMarginTop();
            layoutChild(f, maxWidth-margin, maxHeight);
            int w = f.getWidth();
            int h = f.getHeight();
            lheight = h+margin;
            int x = (maxWidth - w)/2;
            int y = (maxHeight -h)/2;
            setPositionChild( f, x, y);
            setExtent( maxWidth, lheight);
        }
    };
    vfm.add( field);

Upvotes: 2

Related Questions