Android uses rotational animation

Source: Internet
Author: User
<span id="Label3"></p><p><p>Android platform provides two kinds of animation, one is Tween animation, that is, through the scene of the object constantly do image transformation (translation, scaling, Rotation) to produce animation effect, the second class is Frame animation, that is, the sequential playback of Pre-done Images. This paper analyzes the rotate of tween animation to realize the rotation effect. The code is given directly below, and a complete demo is available in the vicinity</p></p><p><p><br></p></p><p><p>Main Class:</p></p><p>public class Mainactivity extends Actionbaractivity {<br>Private ImageView infooperatingiv;<br><br><br>@Override<br>protected void OnCreate (Bundle Savedinstancestate) {<br>Super.oncreate (savedinstancestate);<br>Setcontentview (r.layout.activity_main);<br>Infooperatingiv = (ImageView) Findviewbyid (r.id.infooperating); Picture Object Instantiation<br>Animation Operatinganim = animationutils.loadanimation (this, r.anim.tip); Create animated objects and instantiate, tip-animated files<br>Linearinterpolator lin = new Linearinterpolator ();<br><br>Operatinganim.setinterpolator (lin);<br><br>If (operatinganim! = Null) {<br>Infooperatingiv.startanimation (operatinganim);<br>}<br><br>}</p><p><p><br></p></p><p><p>Layout Activity_main.xml</p></p><p><p><br></p></p><p><p><br></p></p><p><relativelayout xmlns:android= "http://schemas.android.com/apk/res/android"<br>xmlns:tools= "http://schemas.android.com/tools"<br>Android:layout_width= "match_parent"<br>android:layout_height= "match_parent"<br>android:layout_gravity= "center"<br>android:gravity= "center"<br>tools:context= "com.example.testanimation.MainActivity" ><br><br><imageview<br>Android:id= "@+id/infobg"<br>Android:layout_width= "200dp"<br>android:layout_height= "200dp"<br>Android:src= "@drawable/cemung_out_roate"<br>/><br><imageview<br>Android:id= "@+id/infooperating"<br>Android:layout_width= "200dp"<br>android:layout_height= "200dp"<br>Android:src= "@drawable/cemung_in_roate"<br>/><br><br><br></RelativeLayout><br><br>Animation Tip.xml</p><p><p><?xml version= "1.0" encoding= "utf-8"?><br><set xmlns:android= "http://schemas.android.com/apk/res/android" ><br><rotate<br>android:fromdegrees= "0"<br>android:todegrees= "359"<br><br>android:duration= "1300"<br>Android:repeatcount= "-1"<br>android:pivotx= "50%"<br>android:pivoty= "50%"/><br></set><br><br></p></p><p><p>The pictures in the instance are placed in the</p></p><p><p><br></p></p><p><p>Image: cemung_in_roate</p></p><p><p>650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/2A/wKiom1YWJfii2T0VAACbw7Fzn1E087.jpg "style=" float: none; "title=" cemung_in_roate.png "alt=" wkiom1ywjfii2t0vaacbw7fzn1e087.jpg "/> pictures: cemung_out_roate</p></p><p><p>650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/27/wKioL1YWJhDj3NOOAAFKVcrogI8306.jpg "style=" float: none; "title=" cemung_out_roate.png "alt=" wkiol1ywjhdj3nooaafkvcrogi8306.jpg "/></p></p><p><p>Effect</p></p><p><p>The middle of the yellow circle turns<br></p></p><p><p>650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/2A/wKiom1YWJfnz_bayAACpPpQnRm8502.jpg "style=" float: none; "title=" qq20151008161402.png "alt=" wkiom1ywjfnz_bayaacpppqnrm8502.jpg "/></p></p><p><p><br></p></p><p><p><br></p></p><p><p>This article is from the "android spin animation" blog, so be sure to keep this source http://7239441.blog.51cto.com/7229441/1700905</p></p><p><p>Android uses rotational animation</p></p></span>

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.