Android APP欢迎界面小试身手

这是Anny第一次写博客,可谓是处女座啊。写的不好还请手下留情。

第一次写博客,一时间还真的不知道该写些什么内容,思前想后还是来说说比较简单的欢迎界面吧。欢迎动画,说是动画,个人理解也可以不是动画。想要实现的效果无非是类似微信,一张图片闪过;或者像QQ,几张宣传页飘过。第一次写就简单的讲解一下,像微信的那种闪过一张图片的欢迎动画的实现原理。

[1、anim资源文件][anim]
welcom_alpha.xml


<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator">
    <alpha
        android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:duration="2000"
        />
    <alpha
        android:fromAlpha="1.0"
        android:toAlpha="0.0"
        android:startOffset="3000"
    android:duration="3000"
    />
set>

[2、欢迎界面布局][welcom_lay]
activity_welcom.xml


<LinearLayout 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"
    android:orientation="vertical"
    tools:context="com.cl.chengl.WelcomAct">
    <ImageView
        android:id="@+id/welcomImg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/trim"
        android:scaleType="fitXY"
        />

LinearLayout>

[3、欢迎activity][welcom_act]

import android.content.Intent;
import android.os.Bundle;
import android.app.Activity;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

public class WelcomAct extends Activity implements Animation.AnimationListener{
    private ImageView img=null;
    private Animation anim=null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_welcom);

        img=(ImageView)this.findViewById(R.id.welcomImg);
        anim= AnimationUtils.loadAnimation(this,R.anim.welcom_alpha);
        anim.setFillEnabled(true);
        anim.setFillAfter(true);
        img.setAnimation(anim);
        anim.setAnimationListener(this);

    }

    @Override
    public void onAnimationStart(Animation animation) {

    }

    @Override
    public void onAnimationEnd(Animation animation) {
        startActivity(new Intent(this,MainActivity.class));
        finish();
    }

    @Override
    public void onAnimationRepeat(Animation animation) {

    }
}

[4、别忘记了要注册activity][]


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cl.chengl"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">
        activity>
        <activity
            android:name=".WelcomAct"
            android:label="@string/title_activity_welcom">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            intent-filter>
        activity>
    application>

manifest>

[5、图片资源][img]
Android APP欢迎界面小试身手_第1张图片

[6、效果截图][img1]
Android APP欢迎界面小试身手_第2张图片

你可能感兴趣的:(Android,android,界面,动画)