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
Posts: 30
Registered: ‎11-06-2012
My Device: BB 10 Dev Alpha
My Carrier: MegaFon

Center button inside of ScrollView

[ Edited ]

Hi All!

 

Please help me with ScrollView.

I'm trying to display a centered Button inside of Container inside of ScrollView.

 

Without ScrollView the button is centered. When I add ScrollView by uncommenting the lines below, the button becomes top-left aligned.

 

It seems that ScrollView is unable to fill available space horizontally. If I center the ScrollView it works, but dragging area is limited to button width :smileysad:

 

Any help is very appreciated. Thanks!

 

Container {
    horizontalAlignment: HorizontalAlignment.Fill
    verticalAlignment: VerticalAlignment.Fill
    layout: StackLayout {
    }
    //ScrollView {
    //    horizontalAlignment: HorizontalAlignment.Fill
          Button {
              text: qsTr("ButtonText")
              horizontalAlignment: HorizontalAlignment.Center
          }
    //}
}

 

Developer
Posts: 216
Registered: ‎11-05-2011
My Device: Z10
My Carrier: Beeline

Re: Center button inside of ScrollView

Container {
    horizontalAlignment: HorizontalAlignment.Fill
    verticalAlignment: VerticalAlignment.Fill
    layout: StackLayout {
    }
    //ScrollView {
    //    horizontalAlignment: HorizontalAlignment.Fill
Container {
    horizontalAlignment: HorizontalAlignment.Center
    verticalAlignment: VerticalAlignment.Center
    layout: DockLayout {
    }         
          Button {
              text: qsTr("ButtonText")
              horizontalAlignment: HorizontalAlignment.Center
          }
    }
}


// try this solution

 

Developer
Posts: 216
Registered: ‎11-05-2011
My Device: Z10
My Carrier: Beeline

Re: Center button inside of ScrollView

and remove horizontal aligment from button

Developer
Posts: 30
Registered: ‎11-06-2012
My Device: BB 10 Dev Alpha
My Carrier: MegaFon

Re: Center button inside of ScrollView

Thanks! It still doesn't work unless ScrollView is commented out but I need the ScrollView.

 

It seems that ScrollView can't stretch to fill the enclosing container. Any other ideas?

 

New Contributor
Posts: 9
Registered: ‎11-08-2012
My Device: BB 10
My Carrier: Divum

Re: Center button inside of ScrollView

Hi,

 

Please try once using Absolute layout instead of Dock Layout. Let me know if it works.

 

ThankYou.

Developer
Posts: 30
Registered: ‎11-06-2012
My Device: BB 10 Dev Alpha
My Carrier: MegaFon

Re: Center button inside of ScrollView

[ Edited ]

Thanks for your suggestion! I tried substituting DockLayout with AbsoluteLayout but it didn't work.