I wanted a screen in my application which should look like this:
This means the button in the screen should appear in the centre for screen both horizontally and vertically.
Does anyone how to do it. I have written the following code but its not working.
Container *contentContainer = new Container();
contentContainer->setLayout(StackLayout::create());
//contentContainer->setVerticalAlignment(VerticalAlignment::Center);
contentContainer->setHorizontalAlignment(HorizontalAlignment::Center);
Button* submitButton = new Button();
submitButton->setText("Submit");
Button* cancelButton = new Button();
cancelButton->setText("Cancel");
contentContainer->add(submitButton);
contentContainer->add(cancelButton);
Page * testPage = new Page();
testPage ->setContent(contentContainer);
Sheet *testSheet = new Sheet();
testSheet->setContent( LoginSheetPage );
testSheet->open();
To get it center , First you have to create container with docklayout() and inside this container, you have to create stacklayout() with buttons and set docklayout() container as a content of Page.
Container *contentContainer = new Container();
contentContainer->setLayout(StackLayout::create());
contentContainer->setVerticalAlignment(VerticalAlignment::Center);
contentContainer->setHorizontalAlignment(HorizontalAlignment::Center);
Button* submitButton = new Button();
submitButton->setText("Submit");
Button* cancelButton = new Button();
cancelButton->setText("Cancel");
contentContainer->add(submitButton);
contentContainer->add(cancelButton);
Container *rootContainer = new Container();
rootContainer->setLayout(DockLayout::create());
rootContainer->setVerticalAlignment(VerticalAlignment::Fill);
rootContainer->setHorizontalAlignment(HorizontalAlignment::Fill);
rootContainer->add(contentContainer);
Page * testPage = new Page();
testPage ->setContent(rootContainer);