首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何减少溅屏时间

如何减少溅屏时间
EN

Stack Overflow用户
提问于 2020-09-13 18:09:32
回答 1查看 1.3K关注 0票数 1

它需要7-10秒,我想知道有一个方法可以减少时间。在安装启动屏幕之前,主页将在2-3秒内加载。我已经安装了react-native-splash-screen软件包,并使用@bam.tech/react-native-make自动配置了安卓文件。

如果你想知道的话,从没试过真正的设备。

MainActivity.java

代码语言:javascript
复制
package com.myApp;

import android.os.Bundle;
import org.devio.rn.splashscreen.SplashScreen;
import com.facebook.react.ReactActivity;

public class MainActivity extends ReactActivity {

  /**
   * Returns the name of the main component registered from JavaScript. This is used to schedule
   * rendering of the component.
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      SplashScreen.show(this, R.style.SplashScreenTheme);
      super.onCreate(savedInstanceState);
  }

  @Override
  protected String getMainComponentName() {
    return "myApp";
  }
}

AndroidManifest.xml

代码语言:javascript
复制
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myApp">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
        <activity
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
          android:launchMode="singleTask"
          android:windowSoftInputMode="adjustResize">
          <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
        </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

splashscreen.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@color/splashprimary" />
    <item>
        <bitmap
                android:gravity="center"
                android:src="@drawable/splash_image" />
    </item>

</layer-list>

styles.xml

代码语言:javascript
复制
<resources>

    <style name="SplashScreenTheme" parent="SplashScreen_SplashTheme">
        <item name="colorPrimaryDark">@color/splashprimary</item>
        <item name="android:statusBarColor">@color/app_bg</item>
    </style>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:textColor">#000000</item>

        <!-- Add the following line to set the default status bar color for all the app. -->
        <item name="android:statusBarColor">@color/app_bg</item>
        <!-- Add the following line to set the default status bar text color for all the app 
        to be a light color (false) or a dark color (true) -->
        <item name="android:windowLightStatusBar">false</item>
        <!-- Add the following line to set the default background color for all the app. -->
        <item name="android:windowBackground">@color/app_bg</item>
    </style>

</resources>
EN

回答 1

Stack Overflow用户

发布于 2020-09-13 18:25:37

尝试在Style.xml中添加以下内容

代码语言:javascript
复制
<item name="android:windowDisablePreview">true</item>

这将删除开始时出现的白色屏幕。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63874027

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档