1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| public void setTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // 设置状态栏透明 activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // 设置内容布局属性 ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0); contentLayout.setFitsSystemWindows(false); contentLayout.setClipToPadding(true); // 设置抽屉布局属性 // ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1); // vg.setFitsSystemWindows(false); // 设置 DrawerLayout 属性 drawerLayout.setFitsSystemWindows(false); } }
|