react-native APP图标和Splash(Android)
先来看下常用手机分辨率 // mdpi 480*320 // hdpi 800*480 // xhdpi 1280*720 // xhdpi 1920*1080 修改APP名称找到android/app/src/main/AndroidManifest.xml <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:theme="@style/AppTheme"> </application>
找到 android:label = "@string/app_name"。这个对应的就是APP的名称 进入:android/app/src/main/res/valuse/strings.xml目录下 <resources> <string name="app_name">APP名称</string> </resources>
修改APP图标1、找到读取APP图标的地方 进入目录::android/app/src/main/AndroidManifest.xml <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:theme="@style/AppTheme"> </application>
可以看到,icon是在mipmap文件下的ic_launcher图片,因此,在android/app/src/main/res下新建mipmap_hdpi,mipmap_mdpi,mipmap_xhdpi,mipmap_xxhdpi文件,里面分别存放图片ic_launcher, 修改Splash附上地址:https://github.com/crazycodeboy/react-native-splash-screen 安装npm install react-native-splash-screen --save react-native link react-native-splash-screen
检查 linksettings.gradle include ‘:react-native-splash-screen‘ project(‘:react-native-splash-screen‘).projectDir = new File(rootProject.projectDir,‘../node_modules/react-native-splash-screen/android‘)
build.gradle compile project(‘:react-native-splash-screen‘) MainApplication.java import org.devio.rn.splashscreen.SplashScreenReactPackage; new SplashScreenReactPackage()
启动页设置在android/app/src/main/res下新建layout文件,launch_screen.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/launch_screen"> </LinearLayout>
MainActivity.java import android.os.Bundle; import org.devio.rn.splashscreen.SplashScreen; protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(this); // <--添加这一句 super.onCreate(savedInstanceState); }
在android/app/src/main/res下新建drawable_hdpi,drawable_mdpi,drawable_xhdpi,drawable_xxhdpi文件,里面分别存放图片launch_screen, import SplashScreen from ‘react-native-splash-screen‘; componentDidMount() { SplashScreen.hide(); //关闭启动屏幕 }
至此,整个启动页完成了
?
?
1人点赞
?
React-Native
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |