Android_Adaptive_icon 適用しました

参考


動機

Android 8.0(API レベル 26)では、アダプティブ ランチャー アイコンが導入され、デバイスモデルごとに異なる図形を表示できるようになりました。

画像1

Adaptive_iconに適応しなければ、アイコンがこのように中央に小さくロゴが見えるようになる。

始めましょう

1. AndroidManifest.xmlに

    <application
       android:name=".common.PortalApplication"
       android:allowBackup="false"
       android:icon="@drawable/ic_launcher"
       android:label="@string/app_name"
       android:largeHeap="true"
       android:theme="@style/AppTheme"
       android:usesCleartextTraffic="true"
       tools:ignore="LockedOrientationActivity"
       >
       ...

android:icon="@drawable/ic_launcher"

アイコンが drawable に設定されているため、これを mipmap に変える必要があります。

2. drawableの右クリック後、imageAssetをクリックします。

画像2

画像3

親切に アイコンタイプにAdaptive and Legacyが適用されています。 

デザイナーから受けたイメージを入れます。

3. ic_launcher.xmlが作成されます

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
   <background android:drawable="@drawable/ic_launcher_background"/>
   <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

4.AndroidManifest.xmlに戻ります。

   <application
       android:name=".common.PortalApplication"
       android:allowBackup="false"
       android:icon="@mipmap/ic_launcher"
       android:roundIcon="@mipmap/ic_launcher_round"
       android:label="@string/app_name"
       android:largeHeap="true"
       android:theme="@style/AppTheme"
       android:usesCleartextTraffic="true"
       tools:ignore="LockedOrientationActivity"
       >
       ...

ここで

       android:icon="@mipmap/ic_launcher"
       android:roundIcon="@mipmap/ic_launcher_round"

iconとroundIconを指定します。

5. 結果

画像4


この記事が気に入ったらサポートをしてみませんか?