Palo Palo - 9 months ago 50
Android Question

How to scroll to bottom in a ScrollView on activity startup

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

. This works when I make it as an action on button click but it doesn't work in the onCreate method.

Is there any way how to scroll the ScrollView to the bottom on activity startup? That means the view is already scrolled to the bottom when first time displayed.

Answer Source

It needs to be done as following:

    getScrollView().post(new Runnable() {

        public void run() {

This way the view is first updated and then scrolls to the "new" bottom.