DockLayout,可以排列控件在不同的位置,例如上,下,左,右,居中等。
类继承关系:

C++代码实例:
01 | Container* pContainer = new Container(); |
02 | DockLayout *pDockLayout = new DockLayout(); |
03 | pContainer->setLayout(pDockLayout); |
05 | DockLayoutProperties* pProperties = 0; |
09 | Button* pButton1 = Button::create().text( "Button1" ); |
10 | pProperties = DockLayoutProperties::create(); |
11 | pProperties->setHorizontalAlignment(HorizontalAlignment::Center); |
12 | pProperties->setVerticalAlignment(VerticalAlignment::Top); |
13 | pButton1->setLayoutProperties(pProperties); |
17 | Button* pButton2 = Button::create().text( "Button2" ); |
18 | pProperties = DockLayoutProperties::create(); |
19 | pProperties->setHorizontalAlignment(HorizontalAlignment::Right); |
20 | pProperties->setVerticalAlignment(VerticalAlignment::Center); |
21 | pButton2->setLayoutProperties(pProperties); |
23 | pContainer->add( pButton1 ); |
24 | pContainer->add( pButton2 ); |
实现效果:

QML代码实例:
01 | import bb.cascades 1.0 |
11 | layoutProperties: DockLayoutProperties { |
12 | verticalAlignment: VerticalAlignment.Center |
13 | horizontalAlignment: HorizontalAlignment.Right |
18 | layoutProperties: DockLayoutProperties { |
19 | verticalAlignment: VerticalAlignment.Center |
20 | horizontalAlignment: HorizontalAlignment.Center |
25 | layoutProperties: DockLayoutProperties { |
26 | verticalAlignment: VerticalAlignment.Fill |
27 | horizontalAlignment: HorizontalAlignment.Fill |
33 | layoutProperties: DockLayoutProperties { |
34 | verticalAlignment: VerticalAlignment.Bottom |
35 | horizontalAlignment: HorizontalAlignment.Right |
实现效果:

http://www.onmoso.com/blackberry/281.html