Is it possible to make my ScrollView
automaically scroll to the bottom if the height expands? For example, if a Checkbox
is checked and some views are then added to the ScrollView
, they will be "below the current focus" and it might appear as if they were not added.
For automatically scrolling to add the code:
final ScrollView scrollview = ((ScrollView) findViewById(R.id.scrollview));
scrollview.post(new Runnable() {
@Override
public void run() {
scrollview.fullScroll(ScrollView.FOCUS_DOWN);
}
});
Runnable runnable=new Runnable() {
@Override
public void run() {
scrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
};
scrollView.post(runnable);
call this lines every time after adding your view to your layout. That will lead you to initialize Runnable object once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With