这是在fragment中显示,
1 //将导航栏变透明 2 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 3 //透明状态栏 4 // getActivity().getWindow() 5 //.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 6 //隐藏状态栏 7 getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 8 WindowManager.LayoutParams.FLAG_FULLSCREEN); 9 //透明导航栏 10 // getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 11 }
在acticity中直接getWindow即可