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
Developer
Posts: 170
Registered: ‎01-26-2009
My Device: Not Specified
Accepted Solution

ButtonField - UseFullWidth and Center

Hello Everyone

 

Is there a way to center a buttonfield and use the full width inside a horizontalfieldmanager?

 

Thanks

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: ButtonField - UseFullWidth and Center

Befiore we start playing round with styles etc. can you clarify exactly what you want and why

 

1) Do you want the Button the Full Width, or just the size required by the Text?

 

1.a) If not Full width, do you wnat it Centered?

 

2) Why do you want to add a ButtonField to a HorizontalFieldManager?

 

 

 

 

Developer
Posts: 170
Registered: ‎01-26-2009
My Device: Not Specified

Re: ButtonField - UseFullWidth and Center

Hi Peter

 

1) Do you want the Button the Full Width, or just the size required by the Text?

 

Answer: I want button to be the size required by the test. 

 

1.a) If not Full width, do you wnat it Centered?

 

Answer: Yes, I want it Centered.

 

2) Why do you want to add a ButtonField to a HorizontalFieldManager?

 

Answer: I am creating a 3D border for the HorizontalFieldManager and it is last HorizontalFieldManager on the screen. If you have different solution in mind, I can use that too.

 

Thanks

 

 

 

 

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: ButtonField - UseFullWidth and Center

The following was suggested in another post on this forum, I've played around a bit and can't do better.  I think the HorizontablFieldManager does respect FIELD_HCENTER, but VerticalFieldManager does.

 

            HorizontalFieldManager hfmCentre = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);
            VerticalFieldManager vfmCentre = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH);
            ButtonField btn = new ButtonField("center this", ButtonField.FIELD_HCENTER);
            vfmCentre.add(btn);
            hfmCentre.add(vfmCentre);
            this.add(hfmCentre);

Developer
Posts: 170
Registered: ‎01-26-2009
My Device: Not Specified

Re: ButtonField - UseFullWidth and Center

Hi Peter

 

I will take it.

 

Thanks