溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

Android如何實(shí)現(xiàn)應(yīng)用程序的閃屏效果

發(fā)布時(shí)間:2021-04-17 09:46:52 來(lái)源:億速云 閱讀:148 作者:小新 欄目:移動(dòng)開(kāi)發(fā)

這篇文章將為大家詳細(xì)講解有關(guān)Android如何實(shí)現(xiàn)應(yīng)用程序的閃屏效果,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

效果圖:

Android如何實(shí)現(xiàn)應(yīng)用程序的閃屏效果

demo框架如下:

Android如何實(shí)現(xiàn)應(yīng)用程序的閃屏效果

1、閃屏的布局如下:其實(shí)就是一張背景圖

<?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) {
// 
// }
// /** 動(dòng)畫(huà)結(jié)束執(zhí)行的方法*/
// @Override
// public void onAnimationEnd(Animation animation) {
// redirectTo();
// }
// });
 
 /** 方式二*/
 new Handler().postDelayed(new Runnable() {
 
 @Override
 public void run() {
 redirectTo();
 }
 }, 3000);
 }
 /**
 * 即將跳轉(zhuǎn)的頁(yè)面
 */
 public void redirectTo(){
 Intent intent=new Intent(WelcomeActivity.this, MainActivity.class);
 startActivity(intent);
 finish();
 }
}

這樣一個(gè)簡(jiǎn)單的閃屏效果就實(shí)現(xiàn)了呢,而且閃屏效果的實(shí)現(xiàn)有很多都方式,思路就是讓你開(kāi)始的節(jié)面等待個(gè)幾秒鐘,然后顯示。

關(guān)于“Android如何實(shí)現(xiàn)應(yīng)用程序的閃屏效果”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI