Android realizes the effect of the guide page rotating around the center of the ball

Now, many apps will have the guide page effect of Android rotating around the center of the ball, a rotating animation effect similar to the car driving forward all the time.

Let's take a look at the preview effect first:

Well, the overall effect is fairly ideal. The page basically rotates around the center at the bottom of the screen.

Here we use viewflipper, a component of Android system. The main function of this control is to provide animation effect for view switching. The main methods are as follows:

First look at the layout code:

It is mainly a white hemisphere picture at the bottom of the page and three views inside viewflipper. Of course, you can use general layout instead of fragment.

Next is the corresponding activity:

To switch pages by gesture sliding, create a gesturedetector object:

Since we only care about the left and right sliding of fingers, we can rewrite onfling() of simpleongesturelistener, and then bind gesture monitoring in ontouchevent(). At this point, our activity can slide accordingly.

In the onFling () method, when you slide from right to left, set the animation from the right side of the flipper and the animation left from the left side through setInAnimation () and setOutAnimation (). Then call showNext () to start the switch to the next page, so that you can see the corresponding animation effect. The situation is similar when sliding from left to right. You also need to set the animation of view entry and exit, and then switch to the previous page through the showprevious() method.

Specific animation files can refer to the source code, which will not be posted here. Source download

This completes the whole implementation process.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>