先来看下常用手机分辨率 // 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_n
先来看下常用手机分辨率
// 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,
分辨率分别为72x72, 48x48, 96x96, 144x144,192*192
修改Splash
附上地址:https://github.com/crazycodeboy/react-native-splash-screen
安装
npm install react-native-splash-screen --save react-native link react-native-splash-screen
检查 link
settings.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