首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何实现android的斜杠屏幕在反应本机?

如何实现android的斜杠屏幕在反应本机?
EN

Stack Overflow用户
提问于 2022-08-19 19:44:05
回答 1查看 95关注 0票数 0

我正在使用来自https://github.com/zoontek/react-native-bootsplash的这个库https://github.com/zoontek/react-native-bootsplash,我完成了以下步骤:

我编辑了android/build.gradle文件:

代码语言:javascript
复制
buildscript {
  ext {
    buildToolsVersion = "31.0.0"
    minSdkVersion = 23 // <- AndroidX splashscreen has basic support for 21 (only the background color), so 23 is best
    compileSdkVersion = 31 // <- set at least 31
    targetSdkVersion = 31 // <- set at least 31

然后编辑你的android/app/build.gradle文件:

代码语言:javascript
复制
dependencies {
  // …

  implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
  implementation "androidx.core:core-splashscreen:1.0.0" // Add this line

  // …

编辑您的android/app/src/main/res/values/styles.xml文件:

代码语言:javascript
复制
<resources>

  <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
      <!-- Your base theme customization -->
  </style>

  <!-- BootTheme should inherit from Theme.SplashScreen -->
  <style name="BootTheme" parent="Theme.SplashScreen">
    <item name="windowSplashScreenBackground">@color/bootsplash_background</item>
    <item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
    <item name="postSplashScreenTheme">@style/AppTheme</item>
  </style>

</resources>

编辑您的android/app/src/main/AndroidManifest.xml文件:

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

  <!-- … -->

  <application
    android:name=".MainApplication"
    android:label="@string/app_name"
    android:icon="@mipmap/ic_launcher"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:allowBackup="false"
    android:theme="@style/BootTheme"> <!-- Replace @style/AppTheme with @style/BootTheme -->
    <!-- … -->
  </application>
</manifest>

最后编辑您的android/app/src/main/java/com/yourprojectname/MainActivity.java文件:

代码语言:javascript
复制
// …

// Add these required imports:
import android.os.Bundle;
import com.zoontek.rnbootsplash.RNBootSplash;

public class MainActivity extends ReactActivity {

  // …

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    RNBootSplash.init(this); // <- initialize the splash screen
    super.onCreate(savedInstanceState); // or super.onCreate(null) with react-native-screens
  }
}

但是它没有在启动屏幕上显示图标。

EN

回答 1

Stack Overflow用户

发布于 2022-08-20 09:07:38

使用yarn react-native generate-bootsplash <logoPath>

  • Clean生成图标(如果没有),在运行应用程序.

之前,应该使用cd android && ./gradlew clean && cd ..生成编译文件夹。

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

https://stackoverflow.com/questions/73421574

复制
相关文章

相似问题

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