按照Google Developers网站的说明,我成功地创建了我的闪屏。
使用元标签。
<meta-data
android:name="android.support.customtabs.trusted.SPLASH_SCREEN_BACKGROUND_COLOR"
android:resource="@color/colorPrimary"/>
我们可以在应用中显示颜色,但我们可以显示渐变吗?
我试着创建了一个xml渐变,然后用 "元标签 "引用它。android:background
而不是 android:resource
但它没有工作。
我的gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:type="linear"
android:startColor="@color/color1"
android:endColor="@color/color2"
android:angle="135" />
</shape>
我的颜色.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="color1">#fafafa</color>
<color name="color2">#212121</color>
</resources>
而在manifest中添加的snipet。
android:background="@drawable/gradient"
如上所述,如果可能的话,我只是希望能够使用原生TWA元标签来使用闪屏渐变。当我尝试安装.apk时,我得到了错误(无效包)。
只有扁平的颜色才能作为可信网络活动闪屏的背景,目前闪屏不接受可绘制的内容。