zoukankan      html  css  js  c++  java
  • android app 闪屏

    main activity

    package com.splash.screen;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.content.res.Configuration;
    import android.os.Bundle;
    import android.os.Handler;
    import android.util.Log;
    import android.view.Window;
    import android.view.WindowManager;
    import android.view.animation.AlphaAnimation;
    import android.view.animation.Animation;
    import android.widget.ImageView;
    
    import com.newbravo.sg.Game;
    import com.newbravo.sg.R;
    
    /**
     * Created by lyhd on 2016/8/2.
     */
    public class LogoSplashActivity extends Activity {
    
        private  LogoSplashActivity mySplashActivity;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Log.d("LogoSplashActivity","onCreate");
            mySplashActivity = this;
            // 取消标题
            this.requestWindowFeature(Window.FEATURE_NO_TITLE);
            // 取消状态栏
            this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
            setContentView(R.layout.logo_splash);
    
            Log.d("cgz_android: ",this.getExternalFilesDir(null).toString());
    
            //第一种闪屏方式
            // 闪屏的核心代码
    //        new Handler().postDelayed(new Runnable() {
    //            @Override
    //            public void run() {
    //                Intent intent = new Intent(LogoSplashActivity.this,
    //                        Game.class); // 从启动动画ui跳转到主ui
    //                startActivity(intent);
    //                mySplashActivity.overridePendingTransition(R.anim.in_screen,
    //                        R.anim.out_screen);
    //                LogoSplashActivity.this.finish(); // 结束启动动画界面
    //
    //            }
    //        }, 3000); // 启动动画持续3秒钟
    
    
            //第二种方式
    
            ImageView logoImage = (ImageView) this.findViewById(R.id.logo_splash);
            AlphaAnimation alphaAnimation = new AlphaAnimation(0.1f, 1.0f);
            alphaAnimation.setDuration(3000);
            logoImage.startAnimation(alphaAnimation);
            alphaAnimation.setAnimationListener(new Animation.AnimationListener() {
    
                @Override
                public void onAnimationStart(Animation animation) {
    
                }
    
                @Override
                public void onAnimationRepeat(Animation animation) {
    
                }
    
                @Override
                public void onAnimationEnd(Animation animation) {
                    Intent intent = new Intent();
                    intent.setClass(LogoSplashActivity.this, Game.class);
                    intent.setAction(Intent.ACTION_MAIN);
                    intent.addCategory(Intent.CATEGORY_LAUNCHER);
                    startActivity(intent);
                    //startActivity(new Intent("com.google.app.splashy.CLEARSPLASH"));
                    finish();
                }
            });
        }
    
        @Override
        public void onConfigurationChanged(Configuration newConfig) {
            super.onConfigurationChanged(newConfig);
        }
    
        @Override
        protected void onPause() {
            super.onPause();
    
        }
    
        @Override
        protected void onResume() {
            super.onResume();
    
        }
    }

    所用的1个layout

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:id="@+id/logo_splash"
            android:src="@drawable/logo_splash"/>
    </LinearLayout>
  • 相关阅读:
    Js如何动态声明变量名
    vue 生命周期
    开心就要说出来
    为你自己而努力
    vue调试工具
    笨笨对面向对象的理解
    一些小知识点-慢慢更新
    Ajax同时上传表单序列化参数+自定义参数
    关闭layer当前弹窗
    JSTL 递增序号
  • 原文地址:https://www.cnblogs.com/pixs-union/p/8554545.html
Copyright © 2011-2022 走看看