React 原生 Android 应用程序图标/闪屏问题

问题描述 投票:0回答:1

在我的 React Native 应用程序中,当在 Android 上打开时,它会短暂显示一个屏幕,该屏幕的中心是我的应用程序图标,背景为全黑,然后转换到我的启动/加载屏幕。有没有办法使该页面上的背景完全黑色,或者直接进入启动/加载屏幕?下面是我的res目录、styles.xml文件和splashscreen.xml文件

My res directory

splashscreen.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:drawable="@color/splashscreen_background"/>
</layer-list>

样式.xml

<resources xmlns:tools="http://schemas.android.com/tools">
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:textColor">@android:color/black</item>
    <item name="android:editTextStyle">@style/ResetEditText</item>
    <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:windowBackground">@drawable/splashscreen</item>
    <item name="android:windowDisablePreview">true</item>
  </style>
  <style name="ResetEditText" parent="@android:style/Widget.EditText">
    <item name="android:padding">0dp</item>
    <item name="android:textColorHint">#c8c8c8</item>
    <item name="android:textColor">@android:color/black</item>
  </style>
  <style name="Theme.App.SplashScreen" parent="AppTheme">
    <item name="android:windowBackground">@drawable/splashscreen</item>
  </style>

</resources>

我尝试添加一些项目 他们都不起作用

这个问题已经在这里问过,但答案不正确。

Android 上启动屏幕之前显示的应用程序图标

android react-native kotlin
1个回答
0
投票

请将

windowIsTranslucent
设置为
true
style.xml 文件并检查是否有效

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.EdgeToEdge">
    <!-- Customize your theme here. -->
    <item name="android:windowDisablePreview">true</item>
    <item name="android:windowIsTranslucent">true</item> // Add this line
</style>
© www.soinside.com 2019 - 2024. All rights reserved.