刚刚启动android时,有一个空白页面。当然,这个空白页面你可以根据自己需求设置背景颜色:
<item name="android:windowBackground">@color/bg_color</item>
然而,最麻烦的是有部分真机会显示一个logo,无法去掉,特别影响体验。花了很多时间网上搜索解决方法,没有一个可行的。我先借用一下网上一位仁兄的效果图:
上图中,第一个图就是先显示了logo的空白页面,而后才跳转到第二个页面。网上所有的解决办法都无法奏效,很无助。最后,只能自己去尝试根据关键词提示的方式看看有什么主题可以设置。最终,凑巧把这个该死的logo去掉了,大快人心!
首先,在AndroidManifest.xml中,启动页面增加一个主题theme属性,当然后面的名称随意起。
<activity
android:name=".activity.WelcomeActivity"
android:exported="true"
android:icon="@null"
android:label="@string/app_name"
android:theme="@style/Theme.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
然后,在主题中定义如下
<style name="Theme.Splash" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@color/bg_color</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowSplashScreenAnimatedIcon" tools:ignore="NewApi">
@color/bg_color
</item>
</style>
关键是android:windowSplashScreenAnimatedIcon,设置为背景颜色即可。同android:windowBackground设置的背景一致!