content: package com.example.myrecyclviewdemo.weidget;
  
  import android.content.Context;
  import android.graphics.PointF;
  import android.support.v7.widget.LinearSmoothScroller;
  import android.support.v7.widget.RecyclerView;
  import android.support.v7.widget.StaggeredGridLayoutManager;
  import android.util.DisplayMetrics;
  
  /**
   * Created by ruedy on 2017/1/9.
   * 用于改变recycleview加载更多结束以后向上滑动一段距离是，平滑， 可以控制时间
   */
  
  public class MyStaggerGrildLayoutManger extends StaggeredGridLayoutManager {
  
  
      private float MILLISECONDS_PER_INCH = 1f;
      private Context contxt;
  
      public MyStaggerGrildLayoutManger(Context context, int spanCount, int orientation) {
          super(spanCount, orientation);
      }
  
      @Override
      public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
          LinearSmoothScroller linearSmoothScroller =
                  new LinearSmoothScroller(recyclerView.getContext()) {
                      @Override
                      public PointF computeScrollVectorForPosition(int targetPosition) {
  //                        return MyStaggerGrildLayoutManger.this.computeScrollVectorForPosition(targetPosition);
                          return null;
                      }
  
                      //This returns the milliseconds it takes to
                      //scroll one pixel.
                      @Override
                      protected float calculateSpeedPerPixel
                      (DisplayMetrics displayMetrics) {
                          return MILLISECONDS_PER_INCH / displayMetrics.density;
                          //返回滑动一个pixel需要多少毫秒
                      }
  
                  };
          linearSmoothScroller.setTargetPosition(position);
          startSmoothScroll(linearSmoothScroller);
      }
  
  
      public void setSpeedSlow() {
          //自己在这里用density去乘，希望不同分辨率设备上滑动速度相同
          //0.3f是自己估摸的一个值，可以根据不同需求自己修改
          MILLISECONDS_PER_INCH = contxt.getResources().getDisplayMetrics().density * 0.3f;
      }
  
      public void setSpeedFast() {
          MILLISECONDS_PER_INCH = contxt.getResources().getDisplayMetrics().density * 0.03f;
      }
  
  
  }
  