react-native APP圖標(biāo)和Splash(Android)

先來看下常用手機(jī)分辨率

//   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"。這個(gè)對(duì)應(yīng)的就是APP的名稱

進(jìn)入:android/app/src/main/res/valuse/strings.xml目錄下

<resources>
    <string name="app_name">APP名稱</string>
</resources>

修改APP圖標(biāo)

1、找到讀取APP圖標(biāo)的地方

進(jìn)入目錄::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

修改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()
啟動(dòng)頁設(shè)置

在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,
分辨率分別為文章開頭提到的分辨率,
在你首個(gè)頁面增加

import SplashScreen from 'react-native-splash-screen';

componentDidMount() {
        SplashScreen.hide(); //關(guān)閉啟動(dòng)屏幕    
}

至此,整個(gè)啟動(dòng)頁完成了

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,058評(píng)論 25 709
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom閱讀 3,204評(píng)論 0 3
  • 首先,“不能輸在起跑線上”絕對(duì)是一個(gè)坑。如果你想明白了,這句話其實(shí)就是個(gè)廣告。那些各式各樣的輔導(dǎo)班、興趣班的廣告。...
    薛定餓著貓閱讀 269評(píng)論 0 2
  • 上午: 6.40起床 6.50一邊抱娃喂奶,邊做早課 8.00帶娃找奶奶,吃早餐 8.10:查看(重要群)信息,聽...
    瑜伽梅子閱讀 161評(píng)論 0 0

友情鏈接更多精彩內(nèi)容