zoukankan      html  css  js  c++  java
  • Android程序启动加载动画实现

    package com.example.bmob_test.ui;//程序启动动画,图片颜色由浅到深,方法一
    
    
    import com.example.bmob_test.LogActivity;
    import com.example.bmob_test.RegActivity;
    import com.example.bmob_test.R;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.ActionBarActivity;
    import android.view.animation.AlphaAnimation;
    import android.view.animation.Animation;
    import android.view.animation.Animation.AnimationListener;
    import android.widget.ImageView;
    
    public class SplashActivity extends Activity
    {
        private ImageView welcomeImg = null;
    
        @Override
        protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.splash);
            welcomeImg = (ImageView) this.findViewById(R.id.welcome_img);
            AlphaAnimation anima = new AlphaAnimation(0.3f, 1.0f);
            anima.setDuration(3000);// 设置动画显示时间
            welcomeImg.startAnimation(anima);
            anima.setAnimationListener(new AnimationImpl());
    
        }
    
        private class AnimationImpl implements AnimationListener
        {
    
            @Override
            public void onAnimationStart(Animation animation)
            {
                welcomeImg.setBackgroundResource(R.drawable.welcome);
            }
    
            @Override
            public void onAnimationEnd(Animation animation)
            {
                skip(); // 动画结束后跳转到别的页面
            }
    
            @Override
            public void onAnimationRepeat(Animation animation)
            {
    
            }
    
        }
    
        private void skip()
        {
            startActivity(new Intent(this, LogActivity.class));
            finish();
        }
    }

     方法二:

    package com.example.bmob_test.ui;
    
    import com.example.bmob_test.LogActivity;
    import com.example.bmob_test.RegActivity;
    import com.example.bmob_test.R;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Handler;
    import android.support.v7.app.ActionBarActivity;
    import android.view.animation.AlphaAnimation;
    import android.view.animation.Animation;
    import android.view.animation.Animation.AnimationListener;
    import android.widget.ImageView;
    
    public class SplashActivity extends Activity
    {
        private ImageView welcomeImg = null;
    
        @Override
        protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.splash);
            Handler x = new Handler();
            x.postDelayed(new splashhandler(), 3000);
        }
    
        class splashhandler implements Runnable
        {
    
            public void run()
            {
                startActivity(new Intent(getApplication(), LogActivity.class));
                SplashActivity.this.finish();
            }
    
        }
    }
  • 相关阅读:
    万豪酒店数据库遭入侵 5亿顾客信息或泄露
    网络信息安全中最热门的果然是它
    有奖问卷调查丨你有意见?可以提啊!
    业务逻辑漏洞探索之绕过验证
    一个月薪两万的Web安全工程师要掌握哪些技能?
    phpcms2008远程代码执行漏洞
    BASE64编码原理分析脚本实现及逆向案例
    源码级调试的XNU内核
    使用RSA加密在Python中逆向shell
    感恩节活动中奖名单 i春秋喊你领礼物啦!
  • 原文地址:https://www.cnblogs.com/zeze/p/solve7.html
Copyright © 2011-2022 走看看