您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页Android解决启动白屏的问题

Android解决启动白屏的问题

来源:二三四教育网

三种方法:
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简洁

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务