title: Pull to Refresh Auto-Scroll not working properly in Android
body: <p>I am using Pull to Refresh tool on Scroll View with help of this library </p>
  
  <p><a href="https://github.com/chrisbanes/Android-PullToRefresh" rel="nofollow noreferrer">https://github.com/chrisbanes/Android-PullToRefresh</a> </p>
  
  <p>It is working very fine rather than <code>scrollTo(int,int);</code> method
  in My below code I am using this method at last after adding all the items in list.</p>
  
  <p>code is here.</p>
  
  <pre><code>public class MainActivity extends Activity {
  PullToRefreshScrollView mPullRefreshScrollView;
  LinearLayout listHolder;
  ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      listHolder = (LinearLayout) findViewById(R.id.lay);
  
      // initial values in List
      for(int i =0;i&lt;15;i++){
          list.add("InitialValue");
      }
  
      mPullRefreshScrollView = (PullToRefreshScrollView) findViewById(R.id.pull_refresh_scrollview);
      mPullRefreshScrollView
              .setOnRefreshListener(new OnRefreshListener&lt;ScrollView&gt;() {
  
                  @Override
                  public void onRefresh(
                          PullToRefreshBase&lt;ScrollView&gt; refreshView) {
                      new GetDataTask().execute();
                  }
              });
  
      addJournal_Entry_page();
  }
  
  private class GetDataTask extends AsyncTask&lt;Void, Void, String[]&gt; {
      @Override
      protected String[] doInBackground(Void... params) {
          try {
              Thread.sleep(2000);
              for(int i =0;i&lt;4;i++){
                  list.add("InitialValue");
              }
          } catch (InterruptedException e) {
          }
          return null;
      }
  
      @Override
      protected void onPostExecute(String[] result) {
          // Do some stuff here
  
          // Call onRefreshComplete when the list has been refreshed.
          mPullRefreshScrollView.onRefreshComplete();
          addJournal_Entry_page();
          super.onPostExecute(result);
      }
  }
  
  private void addJournal_Entry_page() {
  
      View v;
      listHolder.removeAllViews();
      for (int i = 0; i &lt; list.size(); i++) {
          v = this.getLayoutInflater().inflate(R.layout.list_row, null);
          TextView ind = (TextView)v.findViewById(R.id.index);
          TextView name = (TextView)v.findViewById(R.id.name);
  
          ind.setText(""+i);
          name.setText(list.get(i));
  
          listHolder.addView(v);
      }
  
      Resources r = getResources();
      float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
              100, r.getDisplayMetrics());
  
      //problem is Here
      mPullRefreshScrollView.scrollTo(0,(int)px);
  
  }
  
  }
  </code></pre>
  
  <p>I defined <code>PullToRefreshScrollView</code> in XML like this</p>
  
  <pre><code> &lt;com.handmark.pulltorefresh.library.PullToRefreshScrollView
      xmlns:ptr="http://schemas.android.com/apk/res-auto"
      android:id="@+id/pull_refresh_scrollview"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      ptr:ptrAnimationStyle="flip"
      ptr:ptrMode="pullFromStart" &gt;
  
      &lt;LinearLayout
          android:id="@+id/lay"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical" &gt;
      &lt;/LinearLayout&gt;
  &lt;/com.handmark.pulltorefresh.library.PullToRefreshScrollView&gt;
  </code></pre>
  
  <p>I am getting result like this</p>
  
  <p><img src="https://i.stack.imgur.com/xxYrv.png" alt="enter image description here"></p>
  
  <p>there are 15 items in my list so it should not show white space at bottom of list.</p>
  
  <p>Thanks a lot</p>