@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
View decorView = window.getDecorView();
decorView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
WindowInsets defaultInsets = v.onApplyWindowInsets(insets);
return defaultInsets.replaceSystemWindowInsets(
defaultInsets.getSystemWindowInsetLeft(),
0,
defaultInsets.getSystemWindowInsetRight(),
defaultInsets.getSystemWindowInsetBottom());
}
});
ViewCompat.requestApplyInsets(decorView);
//将状态栏设成透明,如不想透明可设置其他颜色
window.setStatusBarColor(ContextCompat.getColor(this, android.R.color.transparent));
}
registerMessageReceiver(); // used for receive msg
ARouter.getInstance().build(RouterConfig.CURRENT_MAIN).navigation();
finish();
}
<activity android:name=".SplashActivity"
android:theme="@style/SplashTheme"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- 极光推送需要的flag -->
<intent-filter>
<action android:name="jpush.testAction" />
<category android:name="jpush.testCategory" />
</intent-filter>
</activity>
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@mipmap/launchscreen</item>
<item name="android:windowFullscreen">true</item>
<!--不让windowBackground延申到navigation bar区域-->
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>