Simple use of Android animations
This is done by constantly switching pictures to achieve animation effects.
In the layout, define a ImageButton control
and set its position.
Layout file
Very simple, just one control
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent "Tools:context =". Animactivity "> <imageview android:id=" @+id/anim_id "android:layout_width=" 70DP "Android:lay out_height= "50DP" android:layout_centerhorizontal= "true" android:layout_centervertical= "true"/></rela Tivelayout>
Res/anim/anim_test.xml Animation
The inside involves the interval, the picture toggles.
In addition, in the first and last one, I used a transparent picture as a fill.
//To resolve the last picture does not disappear after the animation has finished playing.
<?xml version= "1.0" encoding= "Utf-8"? ><animation-list android:oneshot= "true" xmlns:android= "Http://schemas.android.com/apk/res/android" > < item android:duration= " android:drawable=" @drawable/null_06 " /> <item android:duration= " android:drawable=" @drawable/bs_preview_item_num10 " /> <item android:duration= " android:drawable=" @drawable/bs_preview_item_num9 " /> <item android:duration= " android:drawable=" @drawable/bs_ PREVIEW_ITEM_NUM8 " /> <item android:duration=" android: drawable= "@drawable/bs_preview_item_num7" /> <item android:duration= " " android:drawable=" @drawable/bs_preview_item_num6 " /> <item android:duration= "&NBSP"; android:drawable= "@drawable/bs_preview_item_num5" /> <item android: duration= " android:drawable=" @drawable/bs_preview_item_num4 " /> < item android:duration= " android:drawable=" @drawable/bs_preview_item_num3 " /> <item android:duration= " android:drawable=" @drawable/bs_preview_item_num2 " /> <item android:duration= " android:drawable=" @drawable/bs_ Preview_item_num1 " /> <item android:duration=" android: drawable= "@drawable/null_06" /></animation-list>
Start an animation in a function
Call this method directly to
Play after entering the selection screen
private void Playreadyanim () {//Play animation ImageView animimg = (ImageView) Findviewbyid (r.id.anim_id); Animimg.setbackgroundresource (r.anim.anim_test); Object ob = Animimg.getbackground (); anim = (animationdrawable) ob; Anim.stop (); Anim.start ();}
This article is from the "climb over the mountains to see the Sea" blog, please be sure to keep this source http://670176656.blog.51cto.com/4500575/1601538
Android Frame Toggle Play Animation