如何使用背景图像显示完整的启动画面&我还想显示状态栏背景是什么活动。
以下启动活动有完整的图像它将来可能会改变,现在我做了iugaad显示状态栏背景,但每当我改变我的图像状态栏背景应该该图像。
答案 0 :(得分:11)
您需要执行以下步骤,
<强> V21 / styles.xml 强>
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorStatusBarColor</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<!--Required Api 21 above-->
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
注意:在styles.xml
将AndroidManifest.xml
中的样式应用为`android:theme
android:theme="@style/AppTheme.NoActionBar">
现在只需进入您的活动&amp;在onCreate
方法
private Window mWindow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
mWindow = getWindow();
mWindow.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
立即运行&amp;输出会这样,