Animation changes in Android animation case 3

Source: Internet
Author: User

Today I'm going to say, about the repetitive use of animations.

First, I'm using Java code here to create a alphaanimation to set the properties of the animation. Words not much to say, direct sticker code

Layout file Code

XML code

1  <LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"2 Xmlns:tools= "Http://schemas.android.com/tools"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent"5 android:orientation= "vertical"6 Tools:context= "Com.example.Tween_Animation.Alpha_MainActivity" >7 8     <Button9         Android:id= "@+id/button_scale"Ten Android:layout_width= "Fill_parent" One Android:layout_height= "Wrap_content" A Android:text= "@string/button_stringscaleanimation" /> -  -     <LinearLayout the         android:gravity= "Center" - Android:layout_width= "Fill_parent" - Android:layout_height= "Fill_parent" - android:orientation= "vertical" > +  -         <ImageView +             Android:id= "@+id/imageview_scale" A Android:layout_width= "Wrap_content" at Android:layout_height= "Wrap_content" - android:src= "@drawable/ic_launcher" /> -     </LinearLayout> -  - </LinearLayout>

Activity Code

Java code

1  PackageCom.example.Demo3;2 3 ImportCOM.EXAMPLE.ANDROIDANIMATION.R;4 5 Importandroid.app.Activity;6 ImportAndroid.os.Bundle;7 ImportAndroid.view.View;8 ImportAndroid.view.View.OnClickListener;9 Importandroid.view.animation.AlphaAnimation;Ten Importandroid.view.animation.Animation; One ImportAndroid.widget.Button; A ImportAndroid.widget.ImageView; -  -  Public classMainactivityextendsActivityImplementsonclicklistener{ the     PrivateButton Button =NULL; -     PrivateImageView ImageView =NULL; -     protected voidonCreate (Bundle savedinstancestate) { -         Super. OnCreate (savedinstancestate); + Setcontentview (r.layout.activity_main); -button =(Button) Findviewbyid (R.id.button_scale); +ImageView =(ImageView) Findviewbyid (R.id.imageview_scale); AButton.setonclicklistener ( This); at     } - @Override -      Public voidOnClick (View v) { -         //Create a Alphaanimation object--from 0.0 transparency to 1.0 transparency -Animation Animation =NewAlphaanimation (0.0f, 1.0f); -         //Animation duration--3s inAnimation.setduration (3000); -         //animation Repetition number--5 times toAnimation.setrepeatcount (5); +         //Positive Order (RESTART), reverse order (REVERSE) - Animation.setrepeatmode (animation.reverse); the imageview.startanimation (animation); *     } $     Panax Notoginseng}

Animation changes in Android animation case 3

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.