我在我的布局中定义了一个带有文本编辑框的ScrollView:
<ScrollView android:fillViewport="true"
android:layout_marginBottom="50dip"
android:id="@+id/start_scroller"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:fadingEdge="none">
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TextView>
</ScrollView>
我使用以下方法向这个ScrollView添加文本:
public void writeToLogView(String textMsg) {
if (text.getText().equals("")) {
text.append(textMsg);
} else {
text.append("\n" + textMsg);
scroller.scrollBy(0, 1000000);
}
}
你可以看到,我追加了文本并尝试滚动到ScrollView的底部。不幸的是,这并没有正常工作。它会向下滚动,但并不总是滚动到底部。有什么提示吗?
postDelayed()
,延迟很低,例如20毫秒。 - Snailer