I want to auto scroll an horizontal scrollview which contains a lot of imageview inside a linearlayout when it reached the last imageview the first one appear and so on
I have found this code which have match my needs but when I have added the auto scrolling the circular feature won't work : when the last imageview is reached the first one won't appear
here is my code :
slider = (RelativeLayout)findViewById(R.id.slider);
RelativeLayout container = (RelativeLayout) findViewById(R.id.slider);
scrollView = new PSInfiniteScrollView(this,new PSSize(120,120));
for (int i = 0; i < 10; i++) {
MyCloneableView img = new MyCloneableView(this);
img.setId(i + 20);
img.setImageResource(R.drawable.ic_launcher);
img.setScaleType(ImageView.ScaleType.FIT_XY);
img.setBackgroundColor(c[i]);
img.setTag(c[i]);
scrollView.addItem(img);
}
container.addView(scrollView);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
doLoop();
}
});
t.start();
and here doLoop method :
private void doLoop(){
do {
scrollView.scrollBy(2, 0);
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
scrollView.scrollBy(2, 0);
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
} while (true);
}