国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android冷啟動實現app秒開的實現代碼

2019-10-22 18:29:23
字體:
來源:轉載
供稿:網友

本文介紹了android/277794.html">Android冷啟動實現app秒開的實現代碼,分享給大家,具體如下:

AndroidManifest里對應activity添加屬性android:theme="@style/AppSplash"

<activity      android:name="com.senyint.edu.college.stu.view.activity.SplashActivity"      android:screenOrientation="portrait"      android:theme="@style/AppSplash">      <intent-filter>        <action android:name="android.intent.action.MAIN"/>        <category android:name="android.intent.category.LAUNCHER"/>      </intent-filter>    </activity>

@style/AppSplash:

<style name="AppSplash" parent="Theme.AppCompat.Light.NoActionBar">    <item name="android:windowFullscreen">true</item>    <item name="android:windowBackground">@drawable/splash</item>  </style>

@drawable/splash:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">  <item>    <bitmap      android:src="@mipmap/splash"/>  </item></layer-list>

如此這樣便可以了,當然這只是給用戶的一種感覺,并不是真的“秒開”app。

在一個Activity打開時,如果該Activity所屬的Application還沒有啟動,那么系統會為這個Activity創建一個進程,在進程的創建和初始化中,會消耗一些時間,在這個時間里,WindowManager會先加載APP里的主題樣式里的窗口背景(windowBackground)作為預覽元素,然后才去真正的加載布局。而我上文所做的就是把啟動的界面放在style的windowBackground配置里作為預覽元素呈現給用戶。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到Android開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 仙居县| 灵台县| 包头市| 扶沟县| 九寨沟县| 普定县| 乌拉特前旗| 抚宁县| 洮南市| 交城县| 长垣县| 凌源市| 禄劝| 邛崃市| 鹰潭市| 唐海县| 团风县| 平山县| 钟祥市| 扎囊县| 衢州市| 丘北县| 彭阳县| 宕昌县| 靖边县| 桂平市| 长岭县| 来宾市| 山丹县| 库车县| 霍邱县| 枣阳市| 尉氏县| 桃源县| 霞浦县| 西藏| 奉化市| 甘德县| 宁陕县| 辽宁省| 泰顺县|