单独定义一个静态方法,建立一个线程判断滚动条的内层外层高度变化。
ScrollView scrollresult=(ScrollView)findViewById(R.id.scrollView);
scroll2Bottom(scrollresult, txthistroycontent);//txthistroycontent为滚动条关联的文本框
public static void scroll2Bottom(final ScrollView scroll, final View inner)
{
Handler handler = new Handler();
handler.post(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
if (scroll == null || inner == null) {
return;
}
// 内层高度超过外层
int offset = inner.getMeasuredHeight()
- scroll.getMeasuredHeight();
if (offset < 0) {
System.out.println("定位...");
offset = 0;
}
scroll.scrollTo(0, offset);
}
});
}
}