@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /** * 去掉标题,并使状态栏成为半透明状态 */ getWindow().requestFeature(Window.FEATURE_NO_TITLE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = this.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_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT);//设置状态栏颜色透明 // window.setNavigationBarColor(Color.TRANSPARENT);//设置导航栏颜色透明 } setContentView(R.layout.activity_main); initView(); }
android 让状态栏成为半透明状态
最新推荐文章于 2023-03-20 15:56:53 发布