ionic安卓启动时黑屏解决方法

  1. 在路径为 platforms/android/res/values/ 下新建styles.xml,编辑如下:
<resources>
    <style name="Theme.AppStartLoadTranslucent" parent="android:Theme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>

这个是透明主题,所以有个副作用:当用户切换多个应用的间隙时会存在透明引起的不良体验,但是很少人会注意到。
2. 在 platforms/android/AndroidManifest.xml 中的android:name为”MainActivity”的activity,修改它的theme值,如:android:theme="@style/Theme.AppStartLoadTranslucent"
3. 然后cordova build android就可以啦

  1. 如果需要添加启动图片可以用下面配置
<resources>
    <style name="Theme.AppStartLoadTranslucent" parent="android:Theme">
        <item name="android:windowBackground">@drawable/screen</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>
发布了87 篇原创文章 · 获赞 93 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/zhichaosong/article/details/100785277