Android PWA的启动画面

时间:2018-09-05 06:08:05

标签: android

我正在使用Angular SPA,并且启用了服务程序。我已经在索引页面上添加了manifest.json文件。

现在我要使用两个不同的图标

  1. 当用户说“添加到主屏幕”(添加主屏幕图标)时。
  2. 启动画面图标/图像(从加载应用程序到显示页面的时间所显示的图像)

请参阅下面的代码:

manifest.json

{
  "name": "myApp",
  "short_name": "myApp",
  "theme_color": "#1c4cc3",
  "background_color": "#ffffff",
  "display": "standalone",
  "scope": "/",
  "start_url": "/",
  "icons": [
    {
      "src": "assets/icons/logo-192x192.png",
      "sizes": "192x192",
      "type": "image/png"
    }
  ]
}

将此内容包含在index.html页面中

<link rel="manifest" href="manifest.json">

1 个答案:

答案 0 :(得分:-2)

首先,创建一个可绘制的资源文件:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:opacity="opaque">
    <item android:drawable="@color/colorPrimary"/>
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/icon"/>
    </item>
</layer-list>

然后将其以样式应用于您的活动主题(主题必须分配给Main活动):

<item name="android:windowBackground">@drawable/splash</item>

最后,将其应用于清单上的活动:

android:theme="@style/yourTheme"

你去...