Scrollview Not Scrolling Down Completely
I'm building a chat-like application that displays text the user inputs to the screen using a scrollview. What I'm doing is auto-scrolling the scrollview down as more text is appen
Solution 1:
I looked around, and found that some other people have run into the same problem.
I solved this problem using this piece of code:
finalScrollViewscrollView= (ScrollView) findViewById(R.id.scroll_view);
scrollView.post(newRunnable() {
publicvoidrun() {
scrollView.fullScroll(View.FOCUS_DOWN);
}
});
Hopefully this can help somebody out there!
Solution 2:
Its late but may help some one with this issue.. It takes around 200 miniseconds to add the last element and update it for a scrollView so this will surely work.
voidscrollDown()
{
Thread scrollThread = new Thread(){
publicvoidrun(){
try {
sleep(200);
ChatActivity.this.runOnUiThread(new Runnable() {
publicvoidrun() {
myScrollView.fullScroll(View.FOCUS_DOWN);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
};
scrollThread.start();
}
Just call scrollDown();
after adding element to scrollView.
Solution 3:
Did it this way on Xamarin Android project:
var scrollView = FindViewById<ScrollView>(Resource.Id.scrolview);
scrollView.Post(() =>
{
scrollView.FullScroll(FocusSearchDirection.Down);
});
Thanks to OP.
Solution 4:
@OverridepublicvoidonClick(View v) {
scview_ashora = findViewById(R.id.scview_ashora);
scview_ashora.fullScroll(ScrollView.FOCUS_DOWN);
scview_ashora.postDelayed(newRunnable() {
@Overridepublicvoidrun() {
//replace this line to scroll up or down
scview_ashora.fullScroll(ScrollView.FOCUS_DOWN);
}
}, 1000000L);
}
});
Post a Comment for "Scrollview Not Scrolling Down Completely"