完美解決Android App啟動(dòng)頁(yè)有白屏閃過(guò)的問(wèn)題
應(yīng)用啟動(dòng)的時(shí)候有短暫的白屏,如圖:
可以通過(guò)設(shè)置theme的方式來(lái)解決
<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>
然后重新運(yùn)行程序安裝。
補(bǔ)充知識(shí):解決Android啟動(dòng)頁(yè)白屏及圖片拉伸的問(wèn)題
【Android小知識(shí)】
為了解決Android冷啟動(dòng)延遲、白屏等問(wèn)題,往往會(huì)將啟動(dòng)圖片設(shè)置到styles.xml文件中去,但是直接在style文件中引用圖片的話很大可能會(huì)造成圖片拉伸和變形,所以建議將圖片配置到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='http://www.aoyou183.cn/bcjs/@mipmap/icon_welcome'/> </item></layer-list>
以上這篇完美解決Android App啟動(dòng)頁(yè)有白屏閃過(guò)的問(wèn)題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. idea打開(kāi)多個(gè)窗口的操作方法2. IntelliJ IDEA 統(tǒng)一設(shè)置編碼為utf-8編碼的實(shí)現(xiàn)3. asp知識(shí)整理筆記4(問(wèn)答模式)4. 詳解idea中web.xml默認(rèn)版本問(wèn)題解決5. 解決ajax的delete、put方法接收不到參數(shù)的問(wèn)題方法6. IntelliJ IDEA 2020最新激活碼(親測(cè)有效,可激活至 2089 年)7. jsp EL表達(dá)式詳解8. java 優(yōu)雅關(guān)閉線程池的方案9. idea開(kāi)啟代碼提示功能的方法步驟10. 使用Python爬取Json數(shù)據(jù)的示例代碼
