The implementation uses a background image to do a loop shift animation from left to right.
1. Implement two animation XML files, one starting position in -100%p, and one in 0%p. Set the Repeat property to loop, repeating.
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" Android:interpolator= "@android: Anim/accelerate_interpolator" > <translate android:fromxdelta= "0%p" Android:toxdelta= "100%p" android:repeatmode= "restart" android:interpolator= "@android: Anim/linear_ Interpolator " android:repeatcount=" Infinite " android:duration=" 30000 "/></set>
<?xml version= "1.0" encoding= "Utf-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" Android:interpolator= "@android: Anim/accelerate_interpolator" > <translate android:fromxdelta= " -100%p" Android:toxdelta= "0%p" android:repeatmode= "restart" android:interpolator= "@android: Anim/linear_ Interpolator " android:repeatcount=" Infinite " android:duration=" 30000 "/></set>
2. In the layout of the view, you put two identical view backgrounds, and the view animation corresponds to the above two animation.
<imageview android:id= "@+id/animation_top_left" android:layout_width= "Wrap_content" android: layout_height= "Wrap_content" android:contentdescription= "@string/logo" android:src= "@drawable/home_ Animation_bg "/> <imageview android:id=" @+id/animation_top_right "android:layout_width=" Wrap_ Content " android:layout_height=" wrap_content " android:contentdescription=" @string/logo " android: src= "@drawable/home_animation_bg"/>
Animation anim = animationutils.loadanimation (Mcontext, r.anim.home_animation); ImageView Animationtoprightview = ( ImageView) This.findviewbyid (r.id.animation_top_right); animationtoprightview.startanimation (ANIM);
Animation anim2 = animationutils.loadanimation (Mcontext, r.anim.home_animation2); ImageView Animationtopleftview = ( ImageView) This.findviewbyid (r.id.animation_top_left); Animationtopleftview.startanimation (ANIM2);
Android Loop panning Animation