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" : "[email protected]",
      "scale" : "2x"
    },
    ...
    {
      "size" : "1024x1024",
      "idiom" : "ios-marketing",
      "filename" : "[email protected]",
      "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" : "[email protected]",
      "scale" : "2x"
    },
    {
      "idiom" : "universal",
      "filename" : "[email protected]",
      "scale" : "3x"
    }
  ],
  "info" : {
    "version" : 1,
    "author" : "xcode"
  }
}



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

猜你喜欢

转载自www.cnblogs.com/ssjf/p/12273856.html