1,
ScrollView sc = (ScrollView) findViewById(R.id.scroll);//获得scroll对象
LinearLayout mlayout = (LinearLayout) findViewById(R.id.mlayout);//scrollView中包含的布局对象
2,定义一个Handler private final Handler mHandler = new Handler();
3,实现一个线程 Java代码
private Runnable ScrollRunnable= new Runnable() {
@Override
public 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);
ScrollView强制滑到底部 scroll.fullScroll(View.FOCUS_DOWN)