android启动APP时白屏(黑屏)解决办法

默认情况下启动APP时会出现0.5s左右的白屏然后才会显示自己设定启动页的图片,这样会照成很不好的用户体验;

解决方案:在style中定义一 个theme将启动页的背景图片设置成windowBackground视觉上避免白屏现象

step1:在style中定义them

<style name="SplashTheme" parent="AppTheme">
    <!-- 将splash图片设置在这,这样这张图片将取代白屏 -->
    <item name="android:windowBackground">@drawable/splash</item>
    <item name="android:windowFullscreen">true</item>
</style>
step2:在清单配置文件中给启动页activity制定theme

<activity
    android:name=".activity.SplashActivity"
    android:theme="@style/SplashTheme"
    />

然后重新运行即可。




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章