A piece of commonly used animation effect code of Android (How to Make the clicked image control fly to a specified location)

Source: Internet
Author: User

Android official documentation has a lot of articles and experiences on Developing interface special effects. The reason why I wrote this animated effect code is that I found that many articles use XML resources to deploy various effects, if the effect changes dynamically, for example, if the position of the image I clicked is changed, it needs to fly to a specified position. The Code is as follows:

 

Mgridview. setonitemclicklistener (New onitemclicklistener () {<br/> @ override <br/> Public void onitemclick (adapterview <?> Arg0, view arg1, int arg2, <br/> long arg3) {<br/> animationset set = new animationset (true ); <br/> scaleanimation scaleanim = new scaleanimation (1.0f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f); <br/> set. addanimation (scaleanim); <br/> int left = arg1.getleft (); <br/> int Top = arg1.gettop (); <br/> int Bottom = arg1.getbottom (); <br/> int right = arg1.getright (); <br/> int width = arg1.getwidth (); <br/> int Height = arg1.getheight (); <br/> translateanimation trananim = new translateanimation (<br/> animation. absolute, <br/> arg1.getleft (), animation. absolute, 0, <br/> animation. absolute, arg1.gettop (), <br/> animation. absolute, 512); <br/> set. addanimation (trananim); <br/> set. setinterpolator (selectinterpolator); <br/> set. setduration (800); <br/> arg1.startanimation (SET); <br/>}< br/> }); 

 

Related Article

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.