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
macaronlover
Posts: 101
Registered: ‎01-06-2014
My Device: Q10

Interactive image view

Is it possible to enable the user to double tap to zoom into the image as well as pinch to zoom and press a button in the action bar to zoom in and another to zoom out of the image? Below is code of the image in the page:

 

import bb.cascades 1.2

Page {
    titleBar: TitleBar {
        title: "Image"
    }
    Container {
        layout: DockLayout {}
        ImageView {
            imageSource: "asset:///images/map.png"
            scalingMethod: ScalingMethod.AspectFit
            enabled: false
            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Center
        }
    }
}

 

Developer
macaronlover
Posts: 101
Registered: ‎01-06-2014
My Device: Q10

Re: Interactive image view

Anyone?

Developer
pyth
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane

Re: Interactive image view

[ Edited ]

Hi

 

I think you have to create a scrollview around your imageview, sth like this

 

ScrollView {
    id: scrollView
    scrollViewProperties {
        scrollMode: ScrollMode.Both
        pinchToZoomEnabled: true
    }
    layoutProperties: StackLayoutProperties { spaceQuota: 1.0 }
 
    Container {
        background: Color.LightGray
 
        ImageView {
              //...etc
        }
    }
}

 Also, you should add a double-tap handler, and depending on the current contentScale, you should call

resetViewableArea

or

zoomToPoint

 

 

those should be the same functions to call when you add an action to your action bar

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o