Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 appended to the screen. I'm using

 ScrollView my_scrollview = (ScrollView) findViewById(R.id.scroller);
 my_scrollview.fullScroll(ScrollView.FOCUS_DOWN);

This seems to work, although for some reason, because the keyboard is usually on screen while chatting, when the scrollview scrolls down it doesn't completely - the newest textview added is not displayed (you'll have to manually scroll down to the newest one). How do I go about fixing this?

like image 865
Malfunction Avatar asked Feb 10 '13 18:02

Malfunction


2 Answers

I looked around, and found that some other people have run into the same problem.

I solved this problem using this piece of code:

final ScrollView scrollView = (ScrollView) findViewById(R.id.scroll_view);
scrollView.post(new Runnable() {
    public void run() {
        scrollView.fullScroll(View.FOCUS_DOWN);
    }
});

Hopefully this can help somebody out there!

like image 124
Malfunction Avatar answered Sep 22 '22 18:09

Malfunction


Did it this way on Xamarin Android project:

var scrollView = FindViewById<ScrollView>(Resource.Id.scrolview); 

scrollView.Post(() =>
{
    scrollView.FullScroll(FocusSearchDirection.Down);
});

Thanks to OP.

like image 26
Renato Wong Avatar answered Sep 23 '22 18:09

Renato Wong