@Override protected void onCreate(Bundle arg0) { // TODO Auto-generated method stub super.onCreate(arg0); requestWindowFeature(Window.FEATURE_NO_TITLE); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);//设置顶部状态栏颜色
window.setStatusBarColor(Color.TRANSPARENT);
//设置底部导航栏颜色(有的手机没有)
window.setNavigationBarColor(getResources().getColor(R.color.transparent_20)); }}
Android 5.0及以上系统实现沉浸式状态栏
最新推荐文章于 2024-06-25 03:52:06 发布