Two ways to implement Android zoom animation

Source: Internet
Author: User

Developed on Android. We often use zoom animations, and there are two ways to scale animations in normal situations. One is directly through the Java code to implement, the second is to implement the animation through the configuration file, the following is the basic use of the two animations:

Java Code Implementation:

Create a scaled animation object animation animation = new Scaleanimation (0, 1.0f, 0f, 1.0f); animation.setduration (1500);// Animation time Animation.setrepeatcount (3);//animation repeats the number of times animation.setfillafter (TRUE);//set to True, After the animation conversion is applied imageview1.startanimation (animation);//Start animation

through the configuration file implementation:

1, first to create a Anim file under the Res folder, in Anim to establish a scale.xml file such as the following:

<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" >    <scale         android:duration= "android:fillafter="        true "        android:fromxscale=" 0.0 "        android:fromyscale= "0.0"        android:interpolator= "@android: Anim/accelerate_decelerate_interpolator"        android:pivotx= "0%"        android:pivoty= "50%"        android:toxscale= "1.0"        android:toyscale= "1.0"        / ></set>

2. Loading animation:

Animation Animation = Animationutils.loadanimation (this, r.anim.scale); Imageview1.startanimation (Animation);//Start animation
Case:http://download.csdn.net/detail/u013043346/9374204

Two ways to implement Android zoom animation

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.