Animation synthesis Exercise (Deferred Entry + Page Wizard + text box jitter)

Source: Internet
Author: User

1, Activity_welcome.xml (interface just loaded into the Welcome screen layout)

<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"    android:id= "@+id/ll_welcome_ Root "    android:layout_width=" fill_parent "    android:layout_height=" fill_parent "    android:orientation=" Vertical "     android:background=" @drawable/welcome_back "    android:gravity=" Center_horizontal|bottom ">    <progressbar        android:id= "@+id/progressbar1"        android:layout_width= "Wrap_content"        android: layout_height= "Wrap_content"         android:indeterminatedrawable= "@anim/image_progress"        android: indeterminateduration= "/></linearlayout>"
2, Image_progress.xml (Welcome interface starts, there will be a rotating loading progress bar at the bottom of the screen)

<?xml version= "1.0" encoding= "Utf-8"? ><rotate xmlns:android= "Http://schemas.android.com/apk/res/android"    android:fromdegrees= "0"    android:todegrees= "android:pivotx="    50% "    android:pivoty=" 50% "    android:drawable= "@drawable/progess2"/>

3, Welcomeactivity.java

Package Com.atguigu.l10_app2;import Android.app.activity;import Android.content.intent;import android.os.Bundle; Import Android.os.handler;import Android.os.message;import Android.view.animation.alphaanimation;import Android.view.animation.animation;import Android.view.animation.animation.animationlistener;import android.widget.linearlayout;/** * Welcome Interface * */public Class Welcomeactivity extends Activity {private LinearLayout Ll_welcome _root; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_welcome); ll_welcome_root = (linearlayout) Findviewbyid (R.id.ll_welcome_root);// Call Start animation effect ShowAnimation ();} Accept message, Process message private Handler Handler = new Handler (new Handler.callback () {@Overridepublic Boolean handlemessage (message msg) {if (msg.what==1) {//Received message, start another interface startactivity (new Intent (Welcomeactivity.this, Guide1activity.class));} return true;}); * * Show animation */private void ShowAnimation () {//Set picture background transparency Alphaanimation Animation =New Alphaanimation (0.0f, 1.0f); Animation.setduration (2000);//Set Animation listener Animation.setanimationlistener (new Animationlistener () {@Overridepublic void Onanimationstart (Animation Animation) {} @Overridepublic void Onanimationrepeat (Animation Animation) {} @Overridepublic void Onanimationend (Animation Animation) {// Send delayed empty message handler.sendemptymessagedelayed (1, 1000);}); /Welcome to the interface of the Start animation effect Interface Ll_welcome_root.startanimation (animation);}}
4. Then go to the first wizard interface


Look at the Layout File of wizard interface 1 first

Activity_guide1.xml

<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= "com.atguigu.l10_app2. Guide1activity ">    <textview        android:layout_width=" wrap_content "        android:layout_height=" Wrap_ Content "        android:text=" the first setting "/>    <button        android:layout_width=" Wrap_content "        android: layout_height= "Wrap_content"        android:layout_alignparentbottom= "true"        android:layout_alignparentright = "true"        android:text= "Next"         android:onclick= "Next"/></relativelayout>
Guide1activity.java (code function is to start the Interface Wizard two, and display the wizard interface 1 and 2 transition effect)

Package Com.atguigu.l10_app2;import Android.app.activity;import Android.content.intent;import android.os.Bundle; Import Android.view.view;public class Guide1activity extends Activity {@Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_guide1);} public void Next (View v) {startactivity (new Intent (this, guide2activity.class));// Displays an animated interface toggle Overridependingtransition (r.anim.anim_right_in, r.anim.anim_left_out);}}
Anim_left_out.xml (Current page swipe left)

<?xml version= "1.0" encoding= "Utf-8"? ><translate    xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:fromxdelta=" 0% "    android:toxdelta=" -100% "     android:duration=" "></" Translate>
Anim_right_in.xml (Next page swipe left to go to the current page)

<?xml version= "1.0" encoding= "Utf-8"? ><translate xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:fromxdelta=" 100% "     android:toxdelta=" 0% "    android:duration=" "></translate" >

5, Next Look at the wizard page 2 layout



Activity_guide2.xml (Wizard interface two, layout file)

<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 = "COM.ATGUIGU.L10_APP2." Guide1activity "> <textview android:layout_width=" wrap_content "android:layout_height=" wrap_content "Android:text=" the second setting "/> <button android:id=" @+id/button2 "android:layout_width=" Wrap_conte NT "android:layout_height=" Wrap_content "android:layout_alignparentbottom=" true "android:layout_align Parentright= "true" android:onclick= "Next" android:text= "Next"/> <button android:id= "@+id/but Ton1 "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "Android:layout_alignba        Seline= "@+id/button2" android:layout_alignbottom= "@+id/button2" android:layout_alignparentleft= "true"   android:text= "Previous step"      android:onclick= "Pre"/></relativelayout> 
Guide2activity.java (the Java Code of the wizard, the function is to click on the next one, and click on the previous one, showing the sliding effect of the page toggle)

Package Com.atguigu.l10_app2;import Android.app.activity;import Android.content.intent;import android.os.Bundle; Import Android.view.view;public class Guide2activity extends Activity {@Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_guide2);} public void Next (View v) {startactivity (new Intent (this, mainactivity.class));} public void Pre (View v) {finish ();//Display an interface Toggle animation overridependingtransition (r.anim.anim_left_in, R.anim.anim_right_out );}}

Also attached is an XML file that clicks back to the previous interface

Anim_left_in.xml

<?xml version= "1.0" encoding= "Utf-8"? ><translate    xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:fromxdelta=" -100% "     android:toxdelta=" 0% "    android:duration=" ></translate >
Anim_right_out.xml

<?xml version= "1.0" encoding= "Utf-8"? ><translate    xmlns:android= "http://schemas.android.com/apk/res/ Android "    android:fromxdelta=" 0% "    android:toxdelta=" 100% "     android:duration=" ></translate >


6, next into the main interface (this effect is the text box jitter effect)

Activity_main.xml (first look at the layout file on the main page)

<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= "com.atguigu.l10_app2. Mainactivity ">    <edittext        android:id=" @+id/et_main_number "        android:layout_width=" Fill_parent "        android:layout_height= "wrap_content"        android:text= "@string/hello_world"/>    <button        Android:id= "@+id/button1"        android:layout_width= "wrap_content"        android:layout_height= "Wrap_content"        android:layout_below= "@id/et_main_number"        android:text= "Submission"         android:onclick= "Submit"/></ Relativelayout>
Mainactivity.java

Package Com.atguigu.l10_app2;import Android.app.activity;import Android.os.bundle;import android.view.View;import Android.view.animation.animation;import Android.view.animation.animationutils;import Android.widget.EditText; public class Mainactivity extends Activity {private EditText et_main_number; @Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_main); et_main_number = ( EditText) Findviewbyid (r.id.et_main_number);} public void Submit (View v) {//horizontal vibration Animation animation = Animationutils.loadanimation (this, r.anim.shake); et_main_ Number.startanimation (animation);}}

The need for horizontal vibration is supported by the following XML file

Cycle_6.xml

<?xml version= "1.0" encoding= "Utf-8"? ><cycleinterpolator xmlns:android= "http://schemas.android.com/apk/ Res/android "    android:cycles=" 6 "/>

Shake.xml

<?xml version= "1.0" encoding= "Utf-8"? ><translate    xmlns:android= "http://schemas.android.com/apk/res/ Android "    Android:fromxdelta=" 0.1 "    android:toxdelta=" 1.0 "    android:duration="    android: Interpolator= "@anim/cycle_6" >    <!--configuration file cannot have F appear--></translate>





Animation synthesis Exercise (Deferred Entry + Page Wizard + text box jitter)

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.