I am displaying some data in a ScrollView. On activity startup (method onCreate) I fill the ScrollView with data and want to scroll to the bottom.
I tried to use
Put the following code after your data is added:
final ScrollView scrollview = ((ScrollView) findViewById(R.id.scrollview));
scrollview.post(new Runnable() {
@Override
public void run() {
scrollview.fullScroll(ScrollView.FOCUS_DOWN);
}
});
It needs to be done as following:
getScrollView().post(new Runnable() {
@Override
public void run() {
getScrollView().fullScroll(ScrollView.FOCUS_DOWN);
}
});
This way the view is first updated and then scrolls to the "new" bottom.
scrollView.postDelayed(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
},1000);