Android 2D Flip Demo

Source: Internet
Author: User

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

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.