React Native动态闪屏?

4

我想在我的应用程序中添加一个动态的启动画面,从外部 Web 服务器获取图像。

对于 Android,我通常会使用 mipmap 并创建以下布局:

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

  <item
    android:drawable="@color/gray"/>

  <item>
    <bitmap
      android:gravity="center"
      android:src="@mipmap/splash_screen"/>
  </item>

</layer-list>

问题是我能否使用ReactNative下载图像并将其存储到mimap文件夹中,以便Android在下一次启动时获取它?
当然,我也欢迎其他想法。

1
我不知道关于Android,但iOS上的启动画面必须是捆绑在应用程序中的静态图像。据我所知,在提交到App Store之后你无法更换它们。 - Viktor Sec
如果您正在使用Expo,也许使用https://docs.expo.dev/versions/latest/sdk/splash-screen/可能会有所帮助? - gdvalderrama
1个回答

0
希望这可以帮到你。
window.statusBarColor = R.color.VoiceRecognizerDark


//step2 : changing window layout dimension to place the splash screen above the navigation bar
        val displayMetrics = DisplayMetrics()
        windowManager.defaultDisplay.getMetrics(displayMetrics)
        val height = displayMetrics.heightPixels
        val width = displayMetrics.widthPixels

//        val navigationBarHeight = getNavigationBarHeight()
        window.setLayout(width, height)
        window.setGravity(Gravity.TOP)

//       step3 : here comes the dynamic splash sreen image (png)
        window.setBackgroundDrawableResource(R.drawable.splash_background_min)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接