<style name="SplashTheme" parent="AppTheme">
<item name="android:windowBackground">@mipmap/splash</item>
<item name="android:statusBarColor" tools:ignore="NewApi">@color/white</item>
<item name="android:windowIsTranslucent">true</item>
</style>
複製代碼
<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>
</activity>
複製代碼
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
//將window的背景圖設置爲空
getWindow().setBackgroundDrawable(null);
super.onCreate(savedInstanceState);
}
複製代碼
<style name="SplashTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDisablePreview">true</item>
</style>
複製代碼
/**
* Activity屏蔽物理返回按鈕
*
* @param keyCode
* @param event
* @return
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
}
return super.onKeyDown(keyCode, event);
}
複製代碼