Настройка размера окна просмотра ScrollView в BlackBerry10

Привет, мне нужно настроить окно просмотра ScrollView, чтобы оно отображалось в середине экрана. Я попробовал все свойства, которые я могу придумать.

    Page *page = new Page();
Container *container = new Container();
AbsoluteLayout *absoluteLayout = new AbsoluteLayout();
container->setLayout(absoluteLayout);
for(int y=0;y<1536;y+=256)
{
for(int x=0;x<1536;x+=256)
{
AbsoluteLayoutProperties *imageProperties = AbsoluteLayoutProperties::create().x(x).y(y);
ImageView *imageView = ImageView::create().layoutProperties(imageProperties);
imageView->setImage(Image("assets/tile256.jpg"));
container->add(imageView);
}
}
ScrollView *scrollView = ScrollView::create(container).preferredSize(300,300);
scrollView->setHorizontalAlignment(HorizontalAlignment::Center);
scrollView->setVerticalAlignment(VerticalAlignment::Center);
scrollView->setMaxHeight(300);
scrollView->setMaxWidth(300);
ScrollViewProperties *scrollViewProperties = scrollView->scrollViewProperties();
scrollViewProperties->setScrollMode(ScrollMode::Both);
scrollView->zoomToPoint(300,500,1);
QRectF qRectf = scrollView->viewableArea();
qRectf.setX(300);
qRectf.setY(300);
page->setContent(scrollView);
app->setScene(page);

Вот что я попробовал.

1

Решение

Чтобы закрепить элемент управления в определенной области, установите макет контейнера DockLayout и добавьте в него элементы управления. Таким образом, даже если элемент управления будет расширен / свернут, он будет закреплен в указанной области. Здесь добавьте ScrollView в контейнер и установите этот контейнер в качестве содержимого страницы.

Page *page = new Page();

Container *mainContainer = new Container(); //This is the main container of the page
mainContainer->setLayout(new DockLayout()); //To dock scroll view at center of the screen

Container *container = new Container();
...
...
...
mainContainer->add(scrollView);//Add scroll view to the main container
page->setContent(mainContainer);//Set main container as the content
app->setScene(page);
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector