title: circular auto scrolling horizontalscrollview android
body: <p>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</p>
  
  <p>I have found <a href="http://I%20want%20to%20auto%20scroll%20an%20horizontal%20scrollview%20which%20contains%20a%20lot%20of%20imageview%20inside%20a%20linearlayout%20when%20it%20reached%20the%20last%20imageview%20the%20first%20one%20appear%20and%20so%20on%20%20I%20have%20found%20this%20code%20%20which%20have%20match%20my%20needs%20but%20when%20I%20have%20added%20the%20auto%20scrolling%20the%20circular%20feature%20won&#39;t%20work%20:%20when%20the%20last%20imageview%20is%20reached%20the%20first%20one%20won&#39;t%20appear">this code</a>  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</p>
  
  <p>here is my code : </p>
  
  <pre><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 &lt; 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();
  </code></pre>
  
  <p>and here doLoop method : </p>
  
  <pre><code>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);
  }   
  </code></pre>