Flutter-修改應用名稱、圖標、啟動頁


來源:https://blog.csdn.net/yechaoa/article/details/98958344


雖然flutter可以同時運行在android和ios設備上,但是修改名稱、logo、啟動頁還是需要分開配置的。

修改應用名稱
android
在項目下找到android目錄,依次app》src》main》AndroidManifest.xml,
打開AndroidManifest.xml文件,找到application節點,修改label參數即可

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:icon="@mipmap/ic_logo"
        android:label="玩安卓">
        ...
    </application>

ios
在項目下找到ios目錄,依次Runner》Info.plist,
打開Info.plist文件,參數都是key-string的形式,找到CFBundleName,修改參數即可

<dict>
    ...
    <key>CFBundleName</key>
    <string>玩安卓</string>
    ...
</dict>

 

修改應用圖標
android
在項目下找到android目錄,依次app》src》main》res,然后會有一組mipmap開頭的目錄,即不同目錄存放不同的圖標大小,把我們不同大小的圖標分別放在對應的目錄中。
打開AndroidManifest.xml文件,找到application節點,修改icon參數即可

    <application
        android:name="io.flutter.app.FlutterApplication"
        android:icon="@mipmap/ic_logo"
        android:label="玩安卓">
        ...
    </application>

mipmap-hdpi - 72*72
mipmap-mdpi - 48*48
mipmap-xhdpi - 96*96
mipmap-xxhdpi - 144*144
mipmap-xxxhdpi - 192*192
ios
在項目下找到ios目錄,依次Runner》Assets.xcassets》AppIcon.appiconset,然后會有一組后綴為1x、2x、3x的圖標,根據尺寸存放即可。
在同級目錄的Contents.json文件中修改自己的配置

{
  "images" : [
    {
      "size" : "20x20",
      "idiom" : "iphone",
      "filename" : "Icon-App-20x20@2x.png",
      "scale" : "2x"
    },
    ...
    {
      "size" : "1024x1024",
      "idiom" : "ios-marketing",
      "filename" : "Icon-App-1024x1024@1x.png",
      "scale" : "1x"
    }
  ],
  "info" : {
    "version" : 1,
    "author" : "xcode"
  }
}

 


ios的圖標尺寸較多,可以根據Contents.json文件中的配置挨個去修改,或者只修改通用的即可。


啟動頁
android
在項目下找到android目錄,依次app》src》main》res》drawable》launch_background.xml,

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/white" />

    <!-- You can insert your own image assets here -->
    <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/ic_logo" />
    </item>
</layer-list>

 

只需修改這個文件即可。

其他根據需求也可以自行修改values下的style文件,然后在AndroidManifest.xml文件設置給activity即可。

ios
在項目下找到ios目錄,依次Runner》Assets.xcassets》LaunchImage.imageset,根據需求修改LaunchImage圖片文件,並在同級別的Contents.json文件中配置即可。

{
  "images" : [
    {
      "idiom" : "universal",
      "filename" : "LaunchImage.png",
      "scale" : "1x"
    },
    {
      "idiom" : "universal",
      "filename" : "LaunchImage@2x.png",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "LaunchImage@3x.png",
      "scale" : "3x"
    }
  ],
  "info" : {
    "version" : 1,
    "author" : "xcode"
  }
}

 



github
https://github.com/yechaoa/wanandroid_flutter


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM