完美解決Android App啟動頁有白屏閃過的問題
應(yīng)用啟動的時候有短暫的白屏,如圖:
可以通過設(shè)置theme的方式來解決
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="AppTheme.Transparent"> <item name="android:windowIsTranslucent">true</item> <item name="windowNoTitle">true</item> </style>
在AndroidManifest中使用 AppTheme.Transparent
<activity android:name=".MainActivity" android:theme="@style/AppTheme.Transparent" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
然后重新運行程序安裝。
補充知識:解決Android啟動頁白屏及圖片拉伸的問題
【Android小知識】
為了解決Android冷啟動延遲、白屏等問題,往往會將啟動圖片設(shè)置到styles.xml文件中去,但是直接在style文件中引用圖片的話很大可能會造成圖片拉伸和變形,所以建議將圖片配置到xml中去,最后在style文件中引入xml就可以了,如下代碼所示:
style.xml
<style name="SplashActivityThemes" parent="Theme.AppCompat.NoActionBar"> <item name="android:windowBackground">@drawable/bg_splash</item> <item name="android:windowFullscreen">true</item> </style>
bg_splash.xml
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape> <solid android:color="#FFFFFF"/> </shape> </item> <item android:bottom="50dp"> <bitmap android:gravity="bottom|center_horizontal" android:src="@mipmap/icon_welcome"/> </item> </layer-list>
以上這篇完美解決Android App啟動頁有白屏閃過的問題就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Android 接收推送消息跳轉(zhuǎn)到指定頁面的方法
這篇文章主要介紹了Android 接收推送消息跳轉(zhuǎn)到指定頁面的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-01-01Android StickListView實現(xiàn)懸停效果
這篇文章主要介紹了Android StickListView實現(xiàn)懸停效果的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-06-06Android自定義View實現(xiàn)分段選擇按鈕的實現(xiàn)代碼
這篇文章主要介紹了Android自定義View實現(xiàn)分段選擇按鈕的實現(xiàn)代碼,本文通過實例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2020-12-12Android自定義listview布局實現(xiàn)上拉加載下拉刷新功能
這篇文章主要介紹了Android自定義listview布局實現(xiàn)上拉加載下拉刷新功能,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-12-12Android GestureDetector手勢滑動使用實例講解
這篇文章主要為大家詳細(xì)介紹了Android GestureDetector手勢滑動使用實例,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-07-07從零開始使用gradle配置即可執(zhí)行的Hook庫詳解
這篇文章主要為大家介紹了從零開始使用gradle配置即可執(zhí)行的Hook庫詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-09-09Android?Fragment實現(xiàn)頂部、底部導(dǎo)航欄
這篇文章主要為大家詳細(xì)介紹了Android?Fragment實現(xiàn)頂部、底部導(dǎo)航欄,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-09-09Android Studio控制臺出現(xiàn)中文亂碼(方框)問題解決辦法
這篇文章主要介紹了Android Studio控制臺出現(xiàn)中文亂碼(方框)問題解決辦法的相關(guān)資料,需要的朋友可以參考下2017-06-06Android無障礙監(jiān)聽通知的實戰(zhàn)過程
開發(fā)微動手勢的時候,做了一個通知觸發(fā)的功能,就是在收到某個預(yù)設(shè)的通知的時候,自動觸發(fā)某個動作,因此需要監(jiān)聽通知消息,這篇文章主要給大家介紹了關(guān)于Android無障礙監(jiān)聽通知的相關(guān)資料,需要的朋友可以參考下2022-07-07