美文网首页
Android解决启动白屏的问题

Android解决启动白屏的问题

作者: Small_Cake | 来源:发表于2018-07-12 09:11 被阅读106次

三种方法:
1.设置主题背景透明,微信就是用此办法,在主题样式中加入

<item name="android:windowIsTranslucent">true</item>

缺点:冷启动点击了要等一会才有反应,给人感觉启动慢,在8.0的机子上,如何你还设置了Activity的禁止横屏选项会报错:Only fullscreen activities can request orientation,所以8.0最好不要用此方法
2.在启动页的 super.onCreate(savedInstanceState);方法前加入

getWindow().getDecorView().setBackgroundResource(R.drawable.index_bg);

缺点:还是有白屏,不过白屏时间大大缩短
3.写个样式,然后加入到启动页

<style name="NoWhiteBgTheme" parent="AppTheme">
        <item name="android:windowBackground">@drawable/index_bg</item>
    </style>

在Androidmanifest.xml中的页面配置

<activity android:name=".IndexActivity" android:theme="@style/NoWhiteBgTheme">

缺点:还是有白屏,不过白屏时间缩短一些,没有方法2简洁

相关文章

网友评论

      本文标题:Android解决启动白屏的问题

      本文链接:https://www.haomeiwen.com/subject/kztkpftx.html