Animation Frame Animation Implementation Application Welcome interface

Source: Internet
Author: User

The common implementation of the Android welcome interface can be achieved through the animation frame animation, Viewpager can achieve the sliding effect of the welcome interface. This case introduces animation implementation of the icon welcome animation effect.

(1) Put the prepared picture into the project res/drawable.
Pictures are: a.jpg,b.jpg,c.jpg

(2) Define the animation XML file under the Res/drawable folder of the project, the file name can be customized, such as: A_frame.xml.

<?xml version= "1.0" encoding= "Utf-8"?><animation-list xmlns:android="Http://schemas.android.com/apk/res/android" android:oneshot="true" >        <itemandroid:drawable="@drawable/A"android:duration="$" />                    <itemandroid:drawable="@drawable/b"android:duration="1000" />                    <itemandroid:drawable="@drawable/C"android:duration=" "/>                </animation-list>
android:oneshot="true">表示动画只执行一次,不设置该属性动画将循环播放。

(3) Animate the View control by invoking the start () method of the animationdrawable that represents the animation.

The following splashactivity is the activity that displays the welcome animation, and you are welcome to jump to Mainactivity when the animation is finished.

 PackageCom.example.frame;Importandroid.app.Activity;ImportAndroid.content.Intent;Importandroid.graphics.drawable.AnimationDrawable;ImportAndroid.os.Bundle;ImportAndroid.os.Handler;ImportAndroid.widget.ImageView; Public  class splashactivity extends Activity {    //Animation resource Object    PrivateAnimationdrawable animationdrawable;//Declare control object    PrivateImageView ImageView;PrivateHandler Handler =NewHandler () { Public void Handlemessage(Android.os.Message msg) {intwhat = Msg.what;Switch(what) { Case 1: Animationdrawable.start (); Break; Case 2: Intent Intent =NewIntent (splashactivity. This, Mainactivity.class);                StartActivity (Intent); Finish (); Break;default: Break;    }        }; };@Override    protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate); Setcontentview (R.layout.activity_splash);//Get Control objectImageView = (ImageView) Findviewbyid (R.ID.IMAGEVIEW1);//Set Background resourcesImageview.setbackgroundresource (R.drawable.a_frame); Animationdrawable = (animationdrawable) imageview.getbackground ();//Perform animations to prevent bugs, use the handler mechanism to delay 1 seconds to perform animationsHandler.sendemptymessagedelayed (1, +);//Delay 3 seconds after the animation play ends jump to mainactivityHandler.sendemptymessagedelayed (2, the); }}

Activity_splash.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  =" ${relativepackage}.${activityclass} " >     <ImageViewandroid:id= "@+id/imageview1"android:layout_width=" Match_parent "android:layout_height=" match_parent " />                        </relativelayout>

Androidmanifest.xml need to configure splashactivity first boot

<applicationandroid:allowbackup="true"android:icon="@drawable/ Ic_launcher "android:label=" @string/app_name "android:theme=" @style/apptheme " >                                        <activityandroid:name=". Mainactivity "android:label=" @string/app_name " >                                </activity>        <activityandroid:name=". Splashactivity "android:label=" @string/title_activity_splash " >                                    <intent-filter>                <action android:name="Android.intent.action.MAIN" />                <category android:name="Android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </Application>

Animation Frame Animation Implementation Application Welcome interface

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.