Android App啟動(dòng)圖啟動(dòng)界面(Splash)的簡(jiǎn)單實(shí)現(xiàn)代碼
第一步:創(chuàng)建一個(gè)Activity
第二步:創(chuàng)建一個(gè)新的Activity 命名為Splash
new -> Activity -> Empty Activity
p>第三步:將準(zhǔn)備好的啟動(dòng)圖片放到drawable目錄下,并修改Splash的xml布局文件,如下圖所示
第四步:修改SplashActivity中的代碼如下
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中的代碼
將上述代碼的intent filter標(biāo)簽移動(dòng)到name為.Splash的Activity標(biāo)簽下(將啟動(dòng)頁(yè)面修改為SplashActivity),如下圖
好了,現(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)!
相關(guān)文章:
1. JSP之表單提交get和post的區(qū)別詳解及實(shí)例2. CSS可以做的幾個(gè)令你嘆為觀止的實(shí)例分享3. Xml簡(jiǎn)介_(kāi)動(dòng)力節(jié)點(diǎn)Java學(xué)院整理4. jsp+servlet實(shí)現(xiàn)猜數(shù)字游戲5. javascript xml xsl取值及數(shù)據(jù)修改第1/2頁(yè)6. 低版本IE正常運(yùn)行HTML5+CSS3網(wǎng)站的3種解決方案7. jsp文件下載功能實(shí)現(xiàn)代碼8. 將properties文件的配置設(shè)置為整個(gè)Web應(yīng)用的全局變量實(shí)現(xiàn)方法9. ASP常用日期格式化函數(shù) FormatDate()10. JSP+Servlet實(shí)現(xiàn)文件上傳到服務(wù)器功能
