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