Custom scroll effect for scrollview?

Who knows how to make your own scroll function like fling () or smoothScrollTo ()? I have a class that is extended by ScrollView, but I can’t find out how to do this ...

I want it to work like a run, but backward, and I mean instead of decelerating from a given speed. I want it to accelerate from 0 at the same speed as when slowing down, and then stop scrolling at a given position ...

The effect of Im, aimed at the fact that it looks like a WP7 lock screen, you throw it from the screen up, if your scrollview havent scroll to the end, I want it to "fall", and where I want it to start with speed 0 and increase until it again returns to its original position.

Anyone who could help me or just point me in the right direction?

+4
source share
2 answers

You may be able to get the effect you are looking for by installing another different interpolator on the scroller.

For example, you can try using AccelerateInterpolator.

t

Scroller myScroller = new Scroller(context, new AccelerateInterpolator()); 

EDIT: Don’t forget to read the answers to large pages because my suggestion does not help if you do not want to create your own ScrollView (which is not so bad as you have the source).

+3
source

ScrollView uses a Scroller to determine how fling animation goes. I think you can write a custom Scroller and change the function that defines the motion.

Here is an example about using Scroller and here is Scroller source code .

Unfortunately, I do not know an easier way to use ScrollView your Scroller , except for the ScrollView source and replacing the standard Scroller yours. An alternative is to create a simpler custom scroll.

EDIT

It seems the effect of the Android notification bar. If you do not need him to follow his finger, but only respond to gestures, it should not be too difficult if you use animation and the GestureDetector . Sort of:

touch or slow fling β†’ animated animation;

fast enough launch β†’ slide animation;

If you prefer it to follow your finger (for example, the Android notification bar), you will have to play with the View scrollbar, and I think it will be harder (but you can go and see how they did it).

+1
source

Source: https://habr.com/ru/post/1343852/


All Articles