Layout
<?XML version= "1.0" encoding= "Utf-8"?><Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:id= "@+id/rl"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"android:orientation= "vertical" > <ImageViewAndroid:id= "@+id/imageview"Android:layout_width= "Fill_parent"Android:layout_height= "120DP"Android:background= "@drawable/icon" /> <ImageViewAndroid:id= "@+id/imageview2"Android:layout_width= "Fill_parent"Android:layout_height= "120DP"Android:background= "@drawable/expriment" /></Relativelayout>
Mainactivity
PackageCom.manhua.imagead;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.os.Handler;ImportAndroid.util.Log;Importandroid.view.animation.Animation;ImportAndroid.view.animation.AnimationSet;Importandroid.view.animation.TranslateAnimation;ImportAndroid.widget.ImageView; Public classMainactivityextendsActivity { PublicImageView ImageView; PublicImageView imageView2; PublicAnimation Animation1; PublicAnimation Animation2; Public BooleanJuage =true; Public intImages[] =New int[] {r.drawable.icon, r.drawable.expriment, R.drawable.changer, R.drawable.dataline, R.drawable.preffiticat ION}; Public intCount = 0; PublicHandler Handler =NewHandler (); PublicRunnable Runnable =NewRunnable () {@Override Public voidrun () {//TODO auto-generated Method StubAnimationset AnimationSet1 =NewAnimationset (true); Animationset AnimationSet2=NewAnimationset (true); Imageview2.setvisibility (0); Translateanimation Ta=Newtranslateanimation (animation.relative_to_self, 0f, Animation.relative_to_self, -1f, Animation.relative_to_self, 0f, Animation.relative_to_self, 0f); Ta.setduration (2000); Animationset1.addanimation (TA); Animationset1.setfillafter (true); Ta=NewTranslateanimation (Animation.relative_to_self, 1.0f, Animation.relative_to_self, 0f, Animation.relative_to_self, 0f, Animation.rela Tive_to_self, 0f); Ta.setduration (2000); Animationset2.addanimation (TA); Animationset2.setfillafter (true); Imageview.startanimation (ANIMATIONSET1); Imageview2.startanimation (AnimationSet2); Imageview.setbackgroundresource (Images[count%Images.length]); Count++; Imageview2.setbackgroundresource (Images[count%Images.length]); if(juage) handler.postdelayed (runnable,6000); LOG.I ("Handler", "handler"); } }; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); ImageView=(ImageView) Findviewbyid (R.id.imageview); ImageView2=(ImageView) Findviewbyid (R.ID.IMAGEVIEW2); Imageview2.setvisibility (4); Handler.postdelayed (runnable,2000); } Public voidOnPause () {juage=false; Super. OnPause (); }}
Android Advertising Walk Light