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
Apple recently released the official iOS 11 syste...
In March, a report titled "2017 China Unicor...
Ever since the concept of user growth became popu...
Google released the first Beta version of Android...
A model refers to a formal expression of a practi...
Written by Gou Lijun Black holes are commonplace ...
Source: China Device Evaluation...
Training course content: The course has a total o...
Invisibility has always been a frequently appeari...
There are various forms of case communities , and...
Next, let’s talk about the design forms of market...
In mid-July, I did an online micro-class sharing ...
The Spring Festival has just ended. As a leader i...
Core Tips 1. International crude oil market In Ap...
There is a kind of fruit whose reputation is very...