安卓設定沉浸式的方式---巨簡單
阿新 • • 發佈:2019-02-06
//設定沉浸式 @TargetApi(19) void setbarColor() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); getWindow().setStatusBarColor(this.getResources().getColor(R.color.title)); } else if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.KITKAT) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); } }