成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Android App啟動(dòng)圖啟動(dòng)界面(Splash)的簡(jiǎn)單實(shí)現(xiàn)代碼

瀏覽:49日期:2022-09-24 08:49:53

第一步:創(chuàng)建一個(gè)Activity

Android App啟動(dòng)圖啟動(dòng)界面(Splash)的簡(jiǎn)單實(shí)現(xiàn)代碼

第二步:創(chuàng)建一個(gè)新的Activity 命名為Splash

new -> Activity -> Empty Activity

Android App啟動(dòng)圖啟動(dòng)界面(Splash)的簡(jiǎn)單實(shí)現(xiàn)代碼

p>第三步:將準(zhǔn)備好的啟動(dòng)圖片放到drawable目錄下,并修改Splash的xml布局文件,如下圖所示

Android App啟動(dòng)圖啟動(dòng)界面(Splash)的簡(jiǎn)單實(shí)現(xiàn)代碼

第四步:修改SplashActivity中的代碼如下

Android App啟動(dòng)圖啟動(dòng)界面(Splash)的簡(jiǎn)單實(shí)現(xiàn)代碼

import android.content.Intent;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.WindowManager;public class Splash extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//隱藏狀態(tài)欄 getSupportActionBar().hide();//隱藏標(biāo)題欄 setContentView(R.layout.activity_splash); Thread myThread=new Thread(){//創(chuàng)建子線程 @Override public void run() { try{ sleep(5000);//使程序休眠五秒 Intent it=new Intent(getApplicationContext(),MainActivity.class);//啟動(dòng)MainActivity startActivity(it); finish();//關(guān)閉當(dāng)前活動(dòng) }catch (Exception e){ e.printStackTrace(); } } }; myThread.start();//啟動(dòng)線程}}

注 意

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getSupportActionBar().hide();

需要在 setContentView(R.layout.activity_splash);

之前執(zhí)行

第五步:修改配置文件AndroidManifest中的代碼

Android App啟動(dòng)圖啟動(dòng)界面(Splash)的簡(jiǎn)單實(shí)現(xiàn)代碼 將上述代碼的intent filter標(biāo)簽移動(dòng)到name為.Splash的Activity標(biāo)簽下(將啟動(dòng)頁(yè)面修改為SplashActivity),如下圖 Android App啟動(dòng)圖啟動(dòng)界面(Splash)的簡(jiǎn)單實(shí)現(xiàn)代碼

好了,現(xiàn)在大功告成了,快運(yùn)行代碼試試效果怎么樣

總結(jié)

到此這篇關(guān)于Android App啟動(dòng)圖啟動(dòng)界面(Splash)的簡(jiǎn)單實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Android App啟動(dòng)圖啟動(dòng)界面(Splash)的簡(jiǎn)單實(shí)現(xiàn)內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Android
相關(guān)文章: