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 scrol开发者_开发百科lView 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!
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);
}
});
精彩评论