Does Android Studio automatically scroll down when ScrollView expands?

Is it possible to make mine ScrollViewautomatically scroll down if the height expands? For example, if a is Checkboxchecked and then some views are added to ScrollView, they will be “below the current focus”, and it might seem that they are not added.

+4
source share
2 answers

To automatically scroll to add code:

final ScrollView scrollview = ((ScrollView) findViewById(R.id.scrollview));
scrollview.post(new Runnable() {
    @Override
    public void run() {
        scrollview.fullScroll(ScrollView.FOCUS_DOWN);
    }
});
+4
source
Runnable runnable=new Runnable() {
        @Override
        public void run() {
            scrollView.fullScroll(ScrollView.FOCUS_DOWN);
        }
    };
    scrollView.post(runnable);

call these lines every time after adding your view to the layout. This will initialize the Runnable once.

0
source

Source: https://habr.com/ru/post/1669701/


All Articles