2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Flutter】ランチャースクリーンの設定

Posted at

Flutterを使用している場合のランチャースクリーンの設定方法についてです。

android編

ディレクトリandroid/app/src/main/res/drawable/に設定をしていきます。
スクリーンショット 2020-10-25 18.34.56.png

ランチャー画像の保存

上記drawableディレクトリ直下にランチャースクリーンに表示される画像を配置します。
この記事ではlauncher.pngを配置したこととします。
スクリーンショット 2020-10-25 19.09.43.png

launch_background.xmlの編集

drawableディレクトリ直下に元からあるlaunch_background.xmlにランチャー画像設定を記述します。

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:colorBackground" />

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

上記が初期状態で、こちらに上記画像の設定を記述します。
<item>のコメントを解除して下記の通りに書き換えます。
android:src="@mipmap/launch_image"

android:src="@drawable/launcher"

画像設定を記述したものが下記の通りになります。

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:colorBackground" />

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

背景色設定に関してはdrawableと同階層にあるvaluesディレクトリのcolors.xmlを参照すると、<color name="{カラー設定名称}">#212121</color>というように記載されています。
※この記事内ではカラー設定名称を`bg_color_launcher*と置き換えて記述します。

そちらを<item android:drawable="?android:colorBackground" />に下記の通り、記述していきます。
<item android:drawable="@color/bg_color_launcher" />
@color/bg_color_launcher,@drawable/launcherはエディタ上では赤く表記されていると思いますが問題ないです。

最終的には下記の通りになっていると思います。

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="@color/bg_color_launcher" />

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

こちらで設定完了です。エミュレータなどで確認してみてください。
アプリケーションの起動の際に設定した画像が表示されていれば完成です。

iOS編

iosに関してXcodeで作業します。
iOSのディレクトリ上で右クリックFlutter->Open iOS module in Xcodeを選択するとXcodeが起動します。
スクリーンショット 2020-10-25 19.48.48.png

画像の登録 Assets.xcassets

ランチャー用の画像を登録します。Runner/Assets.xcassetsを選択してください。するとlaunchImageを登録するUIが表示されます。
とりあえず、1x,2x,3xと表示されている上の四角の領域に画像をドラッグしてください。
スクリーンショット 2020-10-25 19.57.12.png

背景色の設定

背景色の設定に関してはLaunchScreen.storyboard->viewを選択状態にして一番右のパレット内にあるBackgroundのセレクトボックスから設定することが可能です。
スクリーンショット 2020-10-25 20.00.51.png

以上でiOSのエミュレータ等で確認してみてください。問題なく表示されると思います。

以上です。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?