Android layout effects (i)

Source: Internet
Author: User

public class Mainactivity extends Activity {alphaanimation animation_alpha; Rotateanimation animation_rotate; Scaleanimation Animation_scale; Translateanimation animation_translate; Animationset animationset;imageview image; @Overrideprotected void OnCreate (Bundle savedinstancestate) { Super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); image= (ImageView) Findviewbyid ( R.id.imageview);//image.setscaletype (SCALETYPE.FIT_XY); Initanimation ();} private void Initanimation () {//Transparency Control animation effect Alphaanimation_alpha=new alphaanimation (0.1f,1.0f);//The first parameter fromalpha is Animation at the beginning of the transparency//second parameter Toalpha for the end of the animation transparency Animation_alpha.setrepeatcount (-1);//Set Loop animation_alpha.setduration (5000);// Set time duration is 5000 milliseconds//rotation effect rotateanimation_rotate = new Rotateanimation (0, -180,rotateanimation.relative_to_self, 0.5f,  Rotateanimation.relative_to_self, 0.5f); The first parameter fromdegrees the rotation angle at the start of the animation//The second parameter todegrees the angle to which the animation is rotated///The third parameter Pivotxtype for the animation on the x-axis relative to the object position type// The fourth parameter pivotxvalue the start position of the animation relative to the object's X coordinate//fifth parameter Pivotxtype for the animation on the y-axis relative to the object position type//VIA parameter pivotyvalue the start position of the animation relative to the object's Y coordinate//animation_rotate.setrepeatcount ( -1); animation_rotate.setduration (3000);// Set time duration to 5000 milliseconds//size stretch animation effect scaleanimation_scale=new Scaleanimation (0.1f,3.0f,0.1f,3.0f,animation.relative_to_self , 0.5f,animation.relative_to_self,0.5f);//The first parameter fromx the scaling dimension on the x-coordinate at the start of the animation//The second parameter tox the scaling dimension on the x-coordinate at the end of the animation//The third parameter fromy the start of the animation y                        Scaling dimensions on coordinates//fourth parameter toy is the scaling dimension on the y-coordinate at the end of the animation/* Description: The above four attribute values 0.0 means that shrinking to no 1.0 means normal no scaling A value of less than 1.0 means that a shrink value greater than 1.0 means that the *///fifth parameter pivotxtype is animated at the x-axis relative to the object position type//sixth parameter pivotxvalue the start position of the animation relative to the object's x-coordinate The seventh parameter Pivotxtype for the animation in the y-axis relative to the object position type//eighth parameter pivotyvalue the start position of the animation relative to the object's y-coordinate animation_scale.setrepeatcount (-1); Animation_scale.setduration (5000);//Set time duration is 5000 milliseconds//Mobile animation effect Translateanimation_translate=new Translateanimation ( 0,-300,0,0);////The first parameter fromxdelta the position of the motion at the start of the animation//The second parameter toxdelta the position of the motion at the end of the animation//The third parameter Fromydelta the movement position on the y-coordinate when the animation starts// The three parameter toydelta is the moving position on the y-coordinate at the end of the animation//animation_translate.setrepeatcount (-1);//Set Animation executionHow many times, if 1 is repeated animation_translate.setduration (3000);//Set time duration is 5000 milliseconds animationset=new animationset (TRUE);// Animationset.addanimation (Animation_alpha);//Transparency Animationset.addanimation (animation_rotate);//rotation// Animationset.addanimation (Animation_scale);//Size Telescopic animationset.addanimation (animation_translate);// Move image.startanimation (Animationset);//Start Playback} @Overridepublic Boolean Oncreateoptionsmenu (Menu menu) {//Inflate the Menu This adds items to the action bar if it is present.getmenuinflater (). Inflate (R.menu.main, menu); return true;}}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android layout effects (i)

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.