赞
踩
<!--欢迎页面theme-->
<style name="app_welcome_theme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/app_welcome_bg</item>
<item name="android:windowFullscreen">true</item>
</style>
使用
/** 1. 设置状态栏透明 */ public void setStatusBarTranslucent(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = activity.getWindow(); window.setNavigationBarColor(Color.BLACK); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); View decorView = window.getDecorView(); int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; decorView.setSystemUiVisibility(option); //透明着色 window.setStatusBarColor(Color.TRANSPARENT); } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //透明化状态栏 setStatusBarTranslucent(this); } }
<!--欢迎页面theme-->
<style name="app_welcome_theme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">@drawable/splash_logos</item>
</style>
使用
//设置状态栏透明 public void setStatusBarTranslucent(Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = activity.getWindow(); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); View decorView = window.getDecorView(); int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE; decorView.setSystemUiVisibility(option); //透明着色 //window.setStatusBarColor(Color.TRANSPARENT); //window.setNavigationBarColor(Color.TRANSPARENT); } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //透明化状态栏 setStatusBarTranslucent(this); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。