On the properties and usage _android of view animation in Android

Source: Internet
Author: User

Brief introduction

Android animation mainly includes view animation and property animation, view animation includes tween animation and frame animation, tween animation includes gradient animation, translation animation, scaling animation, rotating animation.

Basic properties of Tween animation

Target View;

often duration;

Start state fromxxx;

End animation ToXxx;

Start time startoffset;

Repetition times repeatcount;

Timeline Interpolator (interpolation).

code example

XML implementation

<?xml version= "1.0" encoding= "Utf-8"?> <translate xmlns:android= 
"http://schemas.android.com/apk/res/" Android "
 android:fromxdelta=" 0 "
 android:fromydelta=" 0 "
 android:toxdelta=" 100% "
 android: Toydelta= "0"
 android:fillafter= "true"
 android:duration= "3000" >
</translate>

Calling in code

Animation translate = animationutils.loadanimation (context,r.anim.translate);
Imageview.startanimation (translate);

Add:

1. For zooming and rotating animations, there pivotX is one or the pivotY center point for zooming or rotating.

The corresponding attribute values are written in three ways.

· A value of 50 indicates the upper-left corner of the current control plus 50px;

· A percentage of 50% represents 50% of the current control;

· The percentage p 50%p represents 50% of the parent control.

2. In an animation set, you can stratOffset implement multiple animation parallelism and serial effects by setting properties.

Frame animation

The configuration file for frame animation is placed in the drawable directory

<?xml version= "1.0" encoding= "Utf-8"?> <animation-list xmlns:android=
"http://schemas.android.com/apk" /res/android ">
 <item android:drawable=" @drawable/image1 "android:duration="/> <item
 android:drawable= "@drawable/image2" android:duration= "/> <item android:drawable="
 @drawable/image3 " Android:duration= "/>"
</animation-list>
The background
Imageview.setbackgroundresource (R.drawable.frame_anim) need to be set first;
Animationdrawable frameanimation = (animationdrawable) imageview.getbackground ();
Frameanimation.start ();

Summarize

The above is the entire content of this article, I hope this article can be useful for everyone to develop Android, if there is doubt you can message exchange.

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.