在activity中调用以下方法:
/** * Apply KitKat specific translucency. */ private void applyKitKatTranslucency() { // KitKat translucent navigation/status bar. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); SystemBarTintManager mTintManager = new SystemBarTintManager(this); mTintManager.setStatusBarTintEnabled(true); mTintManager.setNavigationBarTintEnabled(true); mTintManager.setTintColor(getResources().getColor(R.color.actionbar_background)); } } @TargetApi(19) private void setTranslucentStatus(boolean on) { Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); }
时间: 2024-10-14 12:00:20