Part of the animation
The animation of Android is divided into scale,rotate,tranlateanimation,alpha these kinds of
Start animation in the following ways:
<span style= "White-space:pre" ></span> t1_icon1.setimageresource (r.drawable.t1_frame_animation); <span style= "font-family:arial, Helvetica, Sans-serif;" >t1_frame_animation This animation is placed under drawable </span> t1_icon1_animationdrawable = (animationdrawable) t1_ Icon1 . getdrawable ();
T1_frame_animation XML is an alternating display of two patterns: <?xml version= "1.0" encoding= "UTF-8"? ><animation-list android:oneshot= " False " xmlns:android=" http://schemas.android.com/apk/res/android "> <item android:duration=" 200 " android:drawable= "@drawable/tutorial1_icon1"/> <item android:duration= "android:drawable=" @ Drawable/tutorial1_icon2 "/></animation-list>
There is another one that is placed under the Anim folder:
<span style= "White-space:pre" ></span> Animation tutorail_rotate = animationutils.loadanimation ( Mainactivity.this, r.anim.tutorail_rotate); T1_icon2.startanimation (tutorail_rotate);
<?xml version= "1.0" encoding= "UTF-8"? ><set xmlns:android= "http://schemas.android.com/apk/res/ Android "> <scale android:interpolator=" @android: Anim/accelerate_decelerate_interpolator "android: duration= "android:pivotx=" 50.0% "android:pivoty=" 50.0% "android:fillafter=" false "android:fromxscale=" 0.0 " Android:toxscale= "1.2" android:fromyscale= "0.0" android:toyscale= "1.2"/> <rotate android:duration= "3000 "android:fromdegrees=" 0.0 "android:todegrees=" 359.0 "android:pivotx=" 50.0% "android:pivoty=" 50.0% "Android: Repeatcount= "Infinite"/></set>
whichThe Pivotx property is the start position of the animation relative to the x-coordinate of the object, usually filled with 50%, which is the center point of the view, repeatecount means the number of repetitions
There is also a layoutanimation:
Load directly in XML
For such a boot page:
The first page of the animation is:
T1_icon1.setimageresource (r.drawable.t1_frame_animation); T1_icon1_animationdrawable = (animationdrawable) t1_icon1 . getdrawable (); T1_icon1_animationdrawable.start (); Animation tutorail_rotate = animationutils.loadanimation (Mainactivity.this, r.anim.tutorail_rotate); T1_icon2.startanimation (tutorail_rotate); Animation tutorail_scalate = animationutils.loadanimation (Mainactivity.this, r.anim.tutorail_scalate); T1_fixed.startanimation (tutorail_scalate); Animation Tutorail_bottom = animationutils.loadanimation (Mainactivity.this, r.anim.tutorail_bottom); T1_next.startanimation (Tutorail_bottom);
<pre name= "code" class= "java" style= "LINE-HEIGHT:18PX;" >tutorail_scalate<span style= "Font-family:consolas, ' Courier New ', Courier, mono, serif;" > For:</span>
<?xml version= "1.0" encoding= "UTF-8"? ><set xmlns:android= "Http://schemas.android.com/apk/res/android" > <scale android:interpolator= "@android: Anim/accelerate_decelerate_interpolator" android:duration= "1000" android:pivotx= "50.0%" android:pivoty= "50.0%" android:fillafter= "false" android:fromxscale= "0.0" android:toXScale= "1.1" android:fromyscale= "0.0" android:toyscale= "1.1"/></set>
<span style= "Font-family:consolas, ' Courier New ', Courier, mono, serif;" >tutorail_bottom to:</span>
<pre name= "code" class= "java" style= "LINE-HEIGHT:18PX;" ><pre name= "code" class= "HTML" ><?xml version= "1.0" encoding= "UTF-8"? ><set android:repeatmode= " Reverse " xmlns:android=" http://schemas.android.com/apk/res/android "> <translate android:duration= "Android:repeatcount=" "Infinite" android:fromxdelta= "0.0" android:toxdelta= "0.0" android:fromydelta= "-15.0" Android:toydelta= "20.0"/> <alpha android:duration= "$" android:repeatcount= "Infinite" Android: Fromalpha= "1.0" android:toalpha= "0.3"/></set>
The layout of the first page is:
<pre name= "code" class= "HTML" ><?xml version= "1.0" encoding= "UTF-8"? ><linearlayout android:gravity= " Center "android:orientation=" vertical "android:background=" @android: Color/white "android:layout_width=" Fill_ Parent "android:layout_height=" fill_parent "xmlns:android=" http://schemas.android.com/apk/res/android "> < ImageView android:id= "@+id/t1_fixed" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:layout_marginbottom= "15.0dip" android:src= "@drawable/tutorial1_fixed"/> <relativelayout android:id= "@+id/center_layout" android:layout_width= "fill_parent" android:layout_height= "Wrap_content" Android:layout_ Centerinparent= "true" > <imageview android:id= "@+id/t1_icon1" android:background= "@drawable/t1_frame_ Animation "android:layout_width=" Wrap_content "android:layout_height=" Wrap_content "android:layout_marginleft=" 180.0dip "android:layout_margintop=" 53.0dip "/> <imageview android:id=" @+id/t1_icon2 "Android:visibility= "visible" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" Android:layout_ margintop= "30.0dip" android:src= "@drawable/tutorial1_icon3" android:layout_below= "@id/t1_icon1" Android:layout_ Centerhorizontal= "true"/> <imageview android:id= "@+id/t1_static" android:visibility= "visible" android:layout _width= "Wrap_content" android:layout_height= "wrap_content" android:src= "@drawable/tutorial1_static" Android: Layout_centerhorizontal= "true"/> <imageview android:id= "@+id/t1_text" android:visibility= "visible" android:l Ayout_width= "Wrap_content" android:layout_height= "wrap_content" android:layout_margintop= "10.0dip" android:src= "@ Drawable/tutorial1_text "android:layout_below=" @id/t1_static "android:layout_centerhorizontal=" true "/> </ relativelayout> <imageview android:id= "@+id/t1_next" android:layout_width= "Wrap_content" Android:layout_ height= "Wrap_content" android:layout_margintop= "20.0dip" android:src= "@drawable/tutoRial_next "/></linearlayout>
The Rockets on page 4th are used:
<span style= "White-space:pre" ></span>t3_icon6.setimageresource (r.drawable.t3_frame_animation);< Span style= "White-space:pre" ></span>animationdrawable t3_icon6_animationdrawable = (AnimationDrawable) t3_ Icon6.getdrawable (); <span style= "White-space:pre" ></span>t3_icon6_animationdrawable.start ();
<pre name= "code" class= "HTML" style= "LINE-HEIGHT:18PX;" >t3_frame_animation is:
<?xml version= "1.0" encoding= "UTF-8"? ><animation-list android:oneshot= "false" xmlns:android= "/HTTP/ Schemas.android.com/apk/res/android "> <item android:duration=" android:drawable= "@drawable/rocket_long"/ > <item android:duration= "android:drawable=" @drawable/rocket_middle "/> <item android:duration=" 70 " android:drawable= "@drawable/rocket_short"/></animation-list>
The Oscillating animation on page fourth reads:
int pivot = Animation.relative_to_self;<span style= "White-space:pre" ></span>cycleinterpolator Interpolator = new Cycleinterpolator (3.0f); <span style= "White-space:pre" ></span>rotateanimation Animation = new Rotateanimation (0,, Pivot, 0.47f, Pivot, 0.05f); <span style= "White-space:pre" ></span> <span style= "White-space:pre" ></span>animation.setduration (animation.setstartoffset);< Span style= "White-space:pre" ></span>animation.setrepeatcount (1);//Animation.infinite<span style= " White-space:pre "></span>animation.setinterpolator (interpolator) <span style=" White-space:pre "> </span>t4_icon1.startanimation (animation);