更新:
您所指的内容在 Android 上称为 Immersive Mode。
从版本 1.4.0 开始,Bubblewrap CLI 在初始化应用程序时评估清单的 display 属性。如果值为fullscreen,它会自动将沉浸式模式应用于您的 TWA。确保在您的网络清单中将 display 设置为 fullscreen。
对于现有应用,更新文件twa-manifest.json 并将display 属性添加/更新为fullscreen,然后运行bubblewrap update 和bubblewrap build。
替代/手动方法:
也可以手动更新 Bubblewrap 创建的项目以使用全屏/沉浸模式:
- 编辑
app/build.gradle 以使用最新版本的android-browser-helper 版本。文件底部的dependencies 部分应如下所示:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:1.3.0'
}
请注意,androidbrowserhelper 的最低版本应为1.3.0。
- 编辑
app/src/main/AndroidManifest.xml 并添加一个新的meta-data 标记,其中android:name 属性设置为android.support.customtabs.trusted.DISPLAY_MODE,android:value 属性设置为immersive 以在activity 标记内使用沉浸式模式:李>
<activity android:name="com.google.androidbrowserhelper.trusted.LauncherActivity"
android:label="@string/launcherName">
...
<meta-data android:name="android.support.customtabs.trusted.FALLBACK_STRATEGY"
android:value="@string/fallbackType" />
<meta-data android:name="android.support.customtabs.trusted.DISPLAY_MODE"
android:value="immersive"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
...
</activity>
现在,当运行bubblewrap build 时,应用程序将使用额外的元标记并以全屏/沉浸式模式启动。