Android實現(xiàn)應用程序的閃屏效果
更新時間:2018年07月04日 11:42:23 作者:bzy601638015
這篇文章主要為大家詳細介紹了Android實現(xiàn)應用程序的閃屏效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
每個應用程序都會有閃屏頁面的,那么接下來就看看閃屏頁面是如何實現(xiàn)的?
效果圖:

demo框架如下:

1、閃屏的布局如下:其實就是一張背景圖
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_app" android:orientation="vertical" > </LinearLayout>
2、WelcomeActivity.java的代碼如下:
package com.example.bamboo_splash;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
public class WelcomeActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
/** 方式一*/
// AlphaAnimation animation=new AlphaAnimation(0.3f, 1f);
// animation.setDuration(3000);
// animation.setAnimationListener(new AnimationListener() {
//
// @Override
// public void onAnimationStart(Animation animation) {
//
// }
//
// @Override
// public void onAnimationRepeat(Animation animation) {
//
// }
// /** 動畫結(jié)束執(zhí)行的方法*/
// @Override
// public void onAnimationEnd(Animation animation) {
// redirectTo();
// }
// });
/** 方式二*/
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
redirectTo();
}
}, 3000);
}
/**
* 即將跳轉(zhuǎn)的頁面
*/
public void redirectTo(){
Intent intent=new Intent(WelcomeActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}
這樣一個簡單的閃屏效果就實現(xiàn)了呢,而且閃屏效果的實現(xiàn)有很多都方式,思路就是讓你開始的節(jié)面等待個幾秒鐘,然后顯示。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- Android實現(xiàn)閃屏效果
- Android 自定義閃屏頁廣告倒計時view效果
- Android中使用Handler及Countdowntimer實現(xiàn)包含倒計時的閃屏頁面
- Android應用閃屏頁延遲跳轉(zhuǎn)的三種寫法
- Android實現(xiàn)閃屏歡迎界面
- Android中閃屏實現(xiàn)方法小結(jié)(普通閃屏、倒計時閃屏、倒計時+動畫閃屏)
- Android切換至SurfaceView時閃屏(黑屏閃一下)以及黑屏移動問題的解決方法
- Android實現(xiàn)閃屏及注冊和登錄界面之間的切換效果
- android實現(xiàn)Splash閃屏效果示例
- Android 實現(xiàn)閃屏頁和右上角的倒計時跳轉(zhuǎn)實例代碼
相關(guān)文章
Android Activity Results API代替onActivityResul
說到onActivityResult,我們已經(jīng)非常熟悉來,通過在A activity啟動B activity并且傳入數(shù)據(jù)到B中,然后在A中通過onActivityResult來接收B中返回的數(shù)據(jù)。在最新的activity-ktx的beta版本中,谷歌已經(jīng)廢棄了onActivityResult2022-09-09
Android RetainFragment狀態(tài)保存的方法
本篇文章主要介紹了Android RetainFragment狀態(tài)保存的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-02-02
Android 用RxBinding與RxJava2實現(xiàn)短信驗證碼倒計時功能
這篇文章主要介紹了Android 用RxBinding與RxJava2實現(xiàn)短信倒計時功能示例,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-10-10

