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
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
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
Please use plain text.
Trusted Contributor
jayvd
Posts: 185
Registered: ‎04-07-2013
My Carrier: Telus

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

what is the purpose of doing that?
jayvdiyk.com
Please use plain text.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Carrier: Vodafone

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

Want to implement functionality like swipe
Rujuta Trivedi
Please use plain text.
Developer
raj_jyani
Posts: 104
Registered: ‎05-11-2011
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
            }

 

Please use plain text.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
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
Please use plain text.
Trusted Contributor
jayvd
Posts: 185
Registered: ‎04-07-2013
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
Please use plain text.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
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
Please use plain text.
Developer
raj_jyani
Posts: 104
Registered: ‎05-11-2011
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"
                }
            }
        }
    }
}

 

Please use plain text.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
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
Please use plain text.
Developer
raj_jyani
Posts: 104
Registered: ‎05-11-2011
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  .

Please use plain text.