How to scroll to bottom in a ScrollView on activity startup

后端 未结 9 1032
Happy的楠姐
Happy的楠姐 2020-11-27 14:38

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

9条回答
  •  一整个雨季
    2020-11-27 15:35

    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.

提交回复
热议问题