Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Scroll from left to right in scrollview using specific buttons.

$
0
0

Hi..

I've a scrollView and added many images to it. It scrolls finely. Now I want to do it using buttons, so that i can scroll over individual images from let to right and vice versa. Here is my code.

controller

function lscroll (e) {
  $.pictureview.scrollTo(0,0 );
}
function rscroll (e) {
    var pictureviewwidth = Ti.Platform.displayCaps.platformWidth*90/100;
    $.pictureview.scrollTo(0, pictureviewwidth );
}
 
 
function pictureshow () {
 
    var leftPlace = 10;
    for(var i =0;i< pictures.length;i++){
        var img = pictures[0];
        length = 70
        var images = Ti.UI.createImageView({
            image: img,
            width:length,
            left:leftPlace,
            height:length,
        });
        $.pictureview.add(images);
        leftPlace += length+10;
    }
 
}
View
<View id="pictures">
    <Button id="leftscroll" onClick="lscroll"></Button>
        <ScrollView id="pictureview"></ScrollView>
        <Button id="rightscroll" onClick="rscroll"></Button>
</View>
Style
"#pictureview":{
 
        scrollType:'horizontal',
        top:'5dp', bottom: '5dp',
        height: '40dp',
        width: '89%',
        backgroundColor: '#585858',
        contentWidth:'auto',
        showHorizontalScrollIndicator:true,
        showVerticalScrollIndicator:true
}
Also I'd like to know how to align the contents(images) to center of scrollview if there is only one or two images.

Please help me.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>