1.編輯 value/styles.xml 加入以下內容

<resources>
...
    <style name="AppTheme.Launcher">
        <item name="android:windowBackground">@drawable/launch_screen</item>
        <!-- Optional, on Android 5+ you can modify the colorPrimaryDark color to match the windowBackground color for further branding-->
        <!-- <item name="colorPrimaryDark">@android:color/white</item> -->
    </style>
...
</resources>

其中 @drawable/launch_screen 目前還沒有,下一步製作。

2.在 drawable 新增 launch_screen.xml,內容如下

<?xml version="1.0" encoding="utf-8"?>
<!-- The android:opacity=”opaque” line — this is critical in preventing a flash of black as your theme transitions. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:opacity="opaque">
  <!-- The background color, preferably the same as your normal theme -->
  <item android:drawable="@android:color/white"/>
  <!-- Your product logo - 144dp color version of your app icon -->
  <item>
    <bitmap
      android:gravity="center"
      android:src="@drawable/your_logo"/>
  </item>
</layer-list>

其中 @drawable/your_logo 就是你想顯示的 logo 圖示

3. SplashActivity

該 Activity 除了在 onCreate 作了特殊處理之外,並沒有其它不同。如下

public class LogoActivity extends Activity {
...
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
  }
...

 

4. 在 AndroidManifest.xml 讓 LogoActivity 套用 AppTheme.Launcher

    <activity
      android:theme="@style/AppTheme.Launcher"
      android:name=".logo.LogoActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>