Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollTo always works, smoothScrollTo only sometimes

Tags:

android

I've subclassed HorizontalScrollView so that I can have some custom scrolling behavior, but have found that smoothScrollTo doesn't always fire. I've had to work around this problem by using the following code:

smoothScrollTo(x, y);
scrollTo(x, y);

This makes sure the scrolling actually gets done even if smoothScrollTo doesn't work, since scrollTo works every time. Why is this happening? How can I get smoothScrollTo to work every time?

like image 561
Brad Avatar asked Sep 07 '13 12:09

Brad


1 Answers

try this:

mScrollView.post(new Runnable() {
        @Override
        public void run() {
            mScrollView.smoothScrollTo(x, y);
        }
    });
like image 178
Micky Avatar answered Sep 21 '22 21:09

Micky