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
On December 14, the WeChat official account annou...
For those who are new to bidding, they often fall...
Recently, many people have asked the following qu...
Wanma’s Douyin book order number matrix project i...
◎ Science and Technology Daily reporter Jin Feng ...
In the past two years, the Internet industry has ...
In the daily operation of the website, the follow...
[[224147]] As blockchain technology becomes more ...
In recent years, as the earlier batches of person...
On September 21, why did Apple's 3D Touch fea...
1. Ideas for fission activities from 0 to 1 I bel...
On November 1st, Skyworth iQiyi Ultra HD Box was ...
Part 01 The significance of DPI research and deve...
In the hot summer, the best way to cool off is to...
Everyone is a manager of time, but most people ju...