我已经尝试使用ScrollView FOCUS_DOWN,但是它并没有滚动到底部,而是在接近底部的位置停止滚动。这个问题必须在添加LinearLayout元素后才能解决。
我的代码:
LinearLayoutView.addView(txtView);
scroll.addView(LinearLayoutView);
scroll.fullScroll(ScrollView.FOCUS_DOWN);
谢谢
使用以下代码进行修复:
scroll.post(new Runnable() {
@Override
public void run() {
scroll.fullScroll(ScrollView.FOCUS_DOWN);
}
});
scroll.scrollTo(0, scroll.getBottom());
this.getListView().setStackFromBottom(true);
this.getListView().setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL)
ListActivity
的,只需将 this.getListView()
替换为相应的列表视图即可。