Fly_Over_Android
Fly_Over_Android

Reputation: 83

ScrollView scroll automaticallly when it is full

I have a ScrollView. There is a 'Add' button in the ScrollView. When clicking the button, a new EditText is created on top of the button. When clicking several tiems, the scrollView is full of EditText and the button is out of bounds. My question is how i can make the ScrollView automatically scroll when the buttton is going to be out of bounds. And make my button staying at the bottom of ScrollView. Thanks!

Upvotes: 0

Views: 1222

Answers (1)

Kishore
Kishore

Reputation: 2051

Make the scroll view to scroll down each time you click the button, try placing the below code in button click listener.

ScrollView.post(new Runnable() {
        @Override
        public void run() {
            ScrollView.fullScroll(ScrollView.FOCUS_DOWN);
        }
    }); 

Upvotes: 2

Related Questions