In XML:
CopyCodeThe Code is as follows: <imageview
Android: Id = "@ + ID/touchview"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: layout_alignparentleft = "true"
Android: layout_centervertical = "true"
Android: src = "@ drawable/touch"/>
In Java:Copy codeThe Code is as follows: mtouchview = (imageview) findviewbyid (R. Id. touchview );
Alphaanimation malphaanimation = new alphaanimation (0.1f, 1.0f); // create an alphaanimation object. The parameters are transparent to opacity.
Malphaanimation. setduration (1000); // sets the animation time.
Malphaanimation. setrepeatcount (animation. Infinite); // defines the animation repetition time.
Malphaanimation. setrepeatmode (animation. Reverse); // defines the animation behavior by setting the repetition time
Mtouchview. setanimation (malphaanimation );
Malphaanimation. Start ();