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: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone
Accepted Solution

How to add views horizontally and use it on scroll

Hi,

 

I need two views to be placed horizontally but they should be seen one by one(one at a time).Need to place them in horizontal scroll,when I scroll it,the second view should be displayed. How can I do that?

Rujuta Trivedi
Developer
Posts: 188
Registered: ‎04-07-2013
My Device: BlackBerry Z10
My Carrier: Telus

Re: How to add views horizontally and use it on scroll

what is the purpose of doing that?
jayvdiyk.com
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: How to add views horizontally and use it on scroll

Want to implement functionality like swipe
Rujuta Trivedi
Developer
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

Re: How to add views horizontally and use it on scroll

Hi,

 

You can use ListView instead.

 

        ListView {
            layout: StackListLayout {
                orientation: LayoutOrientation.LeftToRight
            }

 

Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: How to add views horizontally and use it on scroll

But for listview,I need to add datamode etc right?can I use listview as normal container because I need to place two containers in that

Rujuta Trivedi
Developer
Posts: 188
Registered: ‎04-07-2013
My Device: BlackBerry Z10
My Carrier: Telus

Re: How to add views horizontally and use it on scroll

use a ScrollView and set the scroll mode to Horizontal
jayvdiyk.com
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: How to add views horizontally and use it on scroll

That I have already done,but its not working
Rujuta Trivedi
Highlighted
Developer
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

Re: How to add views horizontally and use it on scroll

Hi,

 

It's working in my code.

 

import bb.cascades 1.0

Page {
    content: ScrollView {
        scrollViewProperties.scrollMode: ScrollMode.Horizontal

        Container {
            layout: StackLayout {
                orientation: LayoutOrientation.LeftToRight
            }

            Container {
                Button {
                    text: "Button"
                }
            }
            Container {
                Button {
                    text: "Button"
                }
            }
            Container {
                Button {
                    text: "Button"
                }
            }
        }
    }
}

 

Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: How to add views horizontally and use it on scroll

Thanks Raj,I did the same.Its working fine.Now the problem is I want to show just one container at a time and show it horizontally centered but right now the second container is slightly shown in first screen(before scrolling). I will try with padding to set gap between them

Rujuta Trivedi
Developer
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

Re: How to add views horizontally and use it on scroll

[ Edited ]

HI,

 

Try to set every container's prefferwidth to 768  .