首先1,
获得 sc = (ScrollView) findViewById(R.id.scroll);//scroll对象 LinearLayout mlayout = (LinearLayout) findViewById(R.id.mlayout);//scrollView中包含的布局对象 2,定义一个Handler private final Handler mHandler = new Handler(); 3,实现一个线程
private Runnable ScrollRunnable= new Runnable() {@Overridepublic void run() {int off = mlayout.getMeasuredHeight() - sc.getHeight();//判断高度 if (off > 0) {sc.scrollBy(0, 30);if (sc.getScrollY() == off) {Thread.currentThread().interrupt();} else {mHandler.postDelayed(this, 1000);}}}};
4,开始滚动
mHandler.post(ScrollRunnable);
5,暂停滚动
mHandler.removeCallbacks(ScrollRunnable);