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

New Contributor
Posts: 8
Registered: ‎02-10-2013
My Device: BB10 Dev Alpha B

Disable scrollview when contents fit on the screen

Is there a way I can dynamically enable/disable a scrollview based on if it's actually necessary for it to scroll. If the contents all fit on the page, then I want scrolling disabled. If the contents do not all fit on the page, I want scrolling enabled. I want to be able to dynamically add containers to the scrollview, and have it automatically enable/disable scrolling. Any suggestions are appreciated!

Posts: 292
Registered: ‎07-25-2008
My Device: Passport

Re: Disable scrollview when contents fit on the screen

I'm not aware of a direct way of doing this.  However, you can use some LayoutUpdateHandler tricks to disable the "overscroll" property of the ScrollView.  To a user, this will have the exact same effect.  Here's an example:



ScrollView {
    id: scrollView
    horizontalAlignment: HorizontalAlignment.Fill
    verticalAlignment: VerticalAlignment.Fill
    scrollViewProperties {
        scrollMode: ScrollMode.Vertical
        overScrollEffectMode: {
            if(scrollViewLayout.layoutFrame.height < containerLayout.layoutFrame.height) {
            } else {
    Container {
        id: container
        layout: StackLayout {
            orientation: LayoutOrientation.TopToBottom

        // Controls go here

        attachedObjects: [
            LayoutUpdateHandler {
                id: containerLayout
    attachedObjects: [
        LayoutUpdateHandler {
            id: scrollViewLayout