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

Native Development

Reply
Developer
tommy20
Posts: 262
Registered: ‎05-18-2011
My Device: Curve 9300, BB10 Dev Alpha C, Z10
Accepted Solution

Problem: Page with TitleBar, Vertical Alignment Center not work on BB 10 keyboard (720x720)

[ Edited ]

Hi,

 

I want to vertically centered align something (e.g., a label) on a page with the following qml, but it does not align as expected on BB keyboard (720x720), it instead always aligns on the top. It does align vertically centered as expected on BB 10 All Touch (768x1280).

 

import bb.cascades 1.0

Page {
    titleBar: TitleBar {
        title: "Title"
    }
    Container {
        layout: DockLayout {
        }
        background: Color.create("#444444")
        verticalAlignment: VerticalAlignment.Fill
        Label {
            text: "label"
            verticalAlignment: VerticalAlignment.Center
        }
    }
}

 I also realise that if I remove the TitleBar, then it aligns as I want. Does anyone has a workaround this? Thanks.

--tom
Developer
jalue
Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10

Re: Problem: Page with TitleBar, Vertical Alignment Center not work on BB 10 keyboard (720x720)

Try it with this:

 

    titleBar: TitleBar {
        title: "Title"
        scrollBehavior: TitleBarScrollBehavior.Sticky
    }

 

Developer
tommy20
Posts: 262
Registered: ‎05-18-2011
My Device: Curve 9300, BB10 Dev Alpha C, Z10

Re: Problem: Page with TitleBar, Vertical Alignment Center not work on BB 10 keyboard (720x720)

[ Edited ]

Thanks very much for the solution which can fix the problem. However, TitleBarScrollBehavior is not available on 10.0 SDK, it is a new feature of 10.1 SDK. The question is how can I make this qml works for both 10.0 and 10.1 without a need of duplicating the project and compiling it for 10.0 and 10.1 separately?

 

For this only property needed to change, "using the static asset selector and managing 2 different branches of the qml files sounds like taking a sledgehammer to crack a nut." (citation)

--tom
Developer
StevenKader
Posts: 648
Registered: ‎02-03-2010
My Device: Z10 LE

Re: Problem: Page with TitleBar, Vertical Alignment Center not work on BB 10 keyboard (720x720)

You can add :  

  preferredHeight: 720.0

 

for the first main container.  To make it work for either Z10 / Q10 just change 720  to full screen height variable.


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
Developer
dridk
Posts: 91
Registered: ‎09-25-2012
My Device: bb10 alpha

Re: Problem: Page with TitleBar, Vertical Alignment Center not work on BB 10 keyboard (720x720)

For me, this method works , but it doesn't take in consideration the titleBar for centering. So my item has a top space shift.... 

 

a lover of Qt