In Android design, card elements are often used, with images or main information displayed on the front and detailed content displayed on the back, such as the word flipping of NetEase Youdao Dictionary and the recipe display of Haidilao. It is very easy to implement card view, but how to implement flip animation?
When I was eating Haidilao on TB, I used Pad to order food and found that the recipe function of the application used card controls, so I was ready to share with you how to implement it. Friends who are interested can go to Haidilao to have a look :) GitHub download address of this article source code https://github.com/SpikeKing/wcl-flip-anim-demo Welcome to follow my GitHub: https://github.com/SpikeKing front page The home page consists of two cards, the front and the back. At the same time, set the click event flipCard.
Logic, initialization animation and camera distance.
Animation Initialize the RightOut and LeftIn animations, using the animation set AnimatorSet. When the right-out animation starts, the click event is invalid, and when the left-in animation ends, the click event is restored.
Right out animation
Rotate 180°, and when halfway rotated, the card disappears. Left entry animation
It is hidden at the beginning, rotates in reverse, and when halfway rotated, the card is revealed. Camera Angle Changing the viewing angle involves rotating the card's Y axis, rotationY, which requires modifying the viewing distance. If it is not modified, it will exceed the screen height and affect the visual experience.
Rotation Control Set the target control for the right-out and left-in animations. The two animations are performed synchronously, and the front and back sides are distinguished.
Animation effects The animation effect is very simple, and the entire logic is less than 50 lines. It's such a fun animation, so use it. OK, that's all! Enjoy it! |
<<: iOS implements the production of complex interfaces with multiple variable cells
>>: Style inheritance relationship in Android
If a car brand with sentiment and history fails t...
Produced by: Science Popularization China Author:...
When the weather gets cold, you can’t live withou...
Fan-shot stills of the drama "Ning An Ru Men...
Recently, an enthusiastic netizen posted a messag...
Author: Sun Taixin, Chief Physician, Beijing Elec...
1. Overall Logic There is only one logic in runni...
This is Sun Jiadong, winner of the Medal of the R...
As a traffic pool with over 100 million daily act...
Entering the digital and information age, the wid...
pua popular explanation, what is PUA? PUA origina...
As the effect of Baidu bidding hosting promotion ...
Although there is no factual evidence to support ...
After the APP is launched, promoting the product ...
If you are also a heavy patient of short videos, ...