欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android:启动动画

程序员文章站 2022-04-28 13:23:16
package com.example.administrator.myapplication; import android.support.v7.app.appcompatactivity;...

package com.example.administrator.myapplication;

import android.support.v7.app.appcompatactivity;

import android.os.bundle;

import android.app.activity;

import android.content.intent;

import android.os.bundle;

import android.view.animation.alphaanimation;

import android.view.animation.animation;

import android.view.animation.animation.animationlistener;

import android.widget.imageview;

public class mainactivity extends appcompatactivity {

imageview welcomeimg= null;

@override

protected void oncreate(bundlesavedinstancestate) {

super.oncreate(savedinstancestate);

setcontentview(r.layout.activity_main);

welcomeimg= (imageview) this.findviewbyid(r.id.welcome_img);

alphaanimation anima = new alphaanimation(0.3f,1.0f);

anima.setduration(2000);// 设置动画显示时间

welcomeimg.startanimation(anima);

anima.setanimationlistener(new animationimpl());

}

private class animationimplimplements animationlistener

{

@override

public void onanimationstart(animationanimation) {

welcomeimg.setbackgroundresource(r.drawable.welcome);

}

@override

public void onanimationend(animationanimation) {

skip(); //动画结束后跳转到别的页面

}

@override

public void onanimationrepeat(animationanimation) {

}

private voidskip() {

intent intent = new intent();

intent.setclass(mainactivity.this, secondactivity.class);

startactivity(intent);

}

}

}