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

Native Development

Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi
Accepted Solution

Center object with object to right

I have a container which is full width of the device, and inside I have a title which is centered perfectly.


However I want to add an image on the very left of the container without effecting the perfect centering of the title. What actually happens is that the title centers in the space left of my image instead of being absolutely center in the top container.


Simplified version of the code below.


Container {
            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Fill
            layout: StackLayout {
                orientation: LayoutOrientation.LeftToRight
            Container {
                layoutProperties: StackLayoutProperties {
                    spaceQuota: 1
                verticalAlignment: VerticalAlignment.Center
                Label {
                    text: titleText
                    verticalAlignment: VerticalAlignment.Center
                    horizontalAlignment: HorizontalAlignment.Center
            ImageButton {
                verticalAlignment: VerticalAlignment.Center
                preferredWidth: 45
                preferredHeight: 60


co-founder of Diaree | BB Dev for PictureThis
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Center object with object to right

As long as you don't mind some potential overlap you can add another container at the root level which has a DockLayout and then place your image in that on the left.

If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.