Android note animation effects (GIF image attached)

Source: Internet
Author: User

Animation is an Animation effect component of android. It can display pages, ListView, and GridView in a brilliant way.

 
This blog briefly introduces four animation effects:

1. AlphaAnimation controls the gradient and transparent animation effect



2. ScaleAnimation controls the size scaling animation effect



3. TranslateAnimation controls the animation effect of screen translation



4. RotateAnimation controls the animation effect of image angle changes

 


 

Use the Code directly. Note: In the onCreate () method of the activity, the code I demonstrated directly loads the animation effect of ListView.

 

[Java] AnimationSet set = new AnimationSet (false );
Animation animation = new AlphaAnimation (); // AlphaAnimation controls the animated Effect of gradient transparency
Animation. setDuration (500); // animation time in milliseconds
Set. addAnimation (animation); // Add an animation set
 
Animation = new TranslateAnimation (1, 13, 10, 50); // ScaleAnimation controls the size scaling animation effect
Animation. setDuration (300 );
Set. addAnimation (animation );
 
Animation = new RotateAnimation (); // TranslateAnimation controls the animation effect of screen translation
Animation. setDuration (300 );
Set. addAnimation (animation );
 
Animation = new ScaleAnimation (5, 0, 2, 0); // RotateAnimation controls the animation effect of image angle changes
Animation. setDuration (300 );
Set. addAnimation (animation );
 
LayoutAnimationController controller = new LayoutAnimationController (set, 1 );
 
 
GridView gridView = (GridView) this. findViewById (R. id. gridview );
GridView. setLayoutAnimation (controller); // sets the animation effect in the GridView.
 
ListView listview = (ListView) this. findViewById (R. id. listview );
Listview. setLayoutAnimation (controller); // sets the animation effect for ListView.


From Scott's column
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.