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 you don’t do a good job of content positioning...
The fourth quarter of 2019 has just passed. What ...
In the Android 15 update, Google continued to opt...
How to make 20,000 yuan a month on a photo site, ...
In the process of information flow advertising , ...
Anyang Tea Mini Program Agents are generally divi...
I have shared the copy for Children’s Day before....
They are both advertising channels , but why are ...
On September 26, WeChat iOS version released the ...
This article will explain the following four poin...
[[164493]] Why do people think that Wall-E and Ba...
Since the beginning of 2015, rumors about the lau...
Tencent took the lead in the last round of financ...
[[425948]] September 27 news: The iOS version of ...
Double Eleven is coming soon! For advertisers, Do...