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
Highlighted
Developer
Posts: 163
Registered: ‎12-06-2012
My Device: Z10, Q10
My Carrier: BlackBerry

Viewport size adjustment of ScrollView in BlackBerry10

Hi I need to adjust the viewport of the ScrollView so that it shows up in the middle of the screen. I tried all the properties that I can think of. Here is what I tried.

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);

 

 

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Viewport size adjustment of ScrollView in BlackBerry10

QRectF qRectf = scrollView->viewableArea();
qRectf.setX(300);
qRectf.setY(300);

This code does nothing - it's modifying the local variable only.

Are you trying to reposition the ScrollView itself or to scroll it's content?

 

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 163
Registered: ‎12-06-2012
My Device: Z10, Q10
My Carrier: BlackBerry

Re: Viewport size adjustment of ScrollView in BlackBerry10

I wanto reposition the viewport of the scrollview. like I have 5x5 image tiles in the scrollview. My view port will be positioned as that only middle 3x3 tiles could be shown and the tiles which are at the sides will be hidden.
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Viewport size adjustment of ScrollView in BlackBerry10

Developer
Posts: 163
Registered: ‎12-06-2012
My Device: Z10, Q10
My Carrier: BlackBerry

Re: Viewport size adjustment of ScrollView in BlackBerry10

Yes I did but it doesnt work Smiley Sad
New Contributor
Posts: 5
Registered: ‎02-02-2013
My Device: bb10
My Carrier: bb10

Re: Viewport size adjustment of ScrollView in BlackBerry10

Hi, How does this solve the problem yet?