如何在启动画面之前删除灰色屏幕 - Ionic 4

How to remove gray screen before splash screen - Ionic 4

有人成功地消除了从 android 设备启动离子应用程序时的灰屏吗? 有没有办法去除这个烦人的灰屏?

我找到了一个解决方案,只需 5 个步骤就可以正常工作。

1.)在project\platforms\android\app\src\main\res\values

里面创建文件名colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="gray">#fff</color>
    <color name="black">#fff</color>
</resources>

2.)然后在project\platforms\android\app\src\main\res\values

里面新建一个文件styles.xml
<resources>
  <style name="SplashTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar">
    <item name="android:windowBackground">@drawable/background_splash</item>
  </style>
</resources>

3.)然后从project\platforms\android\app\src\main打开AndroidManifest.xml,然后搜索android:theme="@android:style/Theme.DeviceDefault.NoActionBar"和替换为 android:theme="@style/SplashTheme"

4.)在project\platforms\android\app\src\main\res

内创建drawable文件夹名

5.) 在 drawable 文件夹中创建一个名为 background_splash.xml 的新文件,代码如下。

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">    
    <item android:drawable="@color/black"/>   
</layer-list>

就是这样。 希望对你有所帮助。

添加

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:cdv="http://cordova.apache.org/ns/1.0"

(如果不存在)在你的 widget 标签中 config.xml 存在于你的项目的根目录中。

然后用

替换主 activity 的 android:theme 值
@android:style/Theme.Light.NoTitleBar.Fullscreen

就是这样。您不需要添加任何自定义样式(如果您不想)。

对我来说,我在 style.xml 文件中添加了这段代码:/Users/User/Development/project/platforms/android/app/src/main/res/values/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="SplashTheme"  parent="Theme.AppCompat.Light.NoActionBar">
      <item name="android:windowIsTranslucent">true</item>
      <item name="android:windowBackground">@android:color/transparent</item>
      <item name="android:windowContentOverlay">@null</item>
      <item name="android:windowNoTitle">true</item>
      <item name="android:windowIsFloating">false</item>
     <item name="android:backgroundDimEnabled">false</item>
    
</style>
</resources>

并编辑了我的 AndroidManifest.xml 文件:android:theme="@style/SplashTheme" 将其添加到 activity