android app 閃屏

來源:互聯網
上載者:User

標籤:閃屏   protected   googl   res   alpha   match   imp   repeat   string   

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>

 

android app 閃屏

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.