Simple implementation of the effect of flipping a picture to another picture.
:
Key code
public class Mainactivity extends Activity {private ImageView imagea;private ImageView imageb;private scaleanimation Sato 0 = new Scaleanimation (1, 0, 1, 1,animation.relative_to_parent, 0.5f, animation.relative_to_parent,0.5f);p rivate Scaleanimation sato1 = new Scaleanimation (0, 1, 1, 1,animation.relative_to_parent, 0.5f, Animation.relative_to_parent, 0.5f); @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Initview (); Findviewbyid (R.id.root). Setonclicklistener (New Onclicklistener () {@Overridepublic void OnClick (View v) {if (imagea.getvisibility () = = view.visible) { Imagea.startanimation (sato0);} Else{imageb.startanimation (Sato0);}});} private void Shwoimagea () {imagea.setvisibility (view.visible); imageb.setvisibility (view.invisible);} private void Showimageb () {imagea.setvisibility (view.invisible); imageb.setvisibility (view.visible);} private void Initview () {Imagea = (ImageView) Findviewbyid (r.id.iva); Imageb = (IMageview) Findviewbyid (R.ID.IVB); Shwoimagea (); sato0.setduration (+); sato1.setduration (500); Sato0.setanimationlistener (New Animationlistener () {@Overridepublic void Onanimationstart (Animation Animation) {// Todo auto-generated method stub} @Overridepublic void Onanimationrepeat (Animation Animation) {//Todo auto-generated Method stub} @Overridepublic void Onanimationend (Animation Animation) {if (imagea.getvisibility () = = view.visible) { Imagea.setanimation (null); Showimageb (); imageb.startanimation (sato1);} Else{imageb.setanimation (null); Shwoimagea (); imagea.startanimation (sato1);}});}}
Demo apk http://pan.baidu.com/s/1sjykO4t
Demo Source Http://pan.baidu.com/s/1dD3YWLz
You are welcome to focus on the Android developer community Public number, the official will not regularly bring you some Android development Quality trial demo or framework, improve the development efficiency of everyone, to provide you with quality assurance of Android demo source.
Scan QR Code attention:
Android 2D Flip Demo