MaterialViewPager
MaterialViewPager copied to clipboard
Status bar not transparent
Great API! After following your instructions I created viewpager but the color of my status bar is still colorPrimaryDark. I have copied your theme. I have tried setting flags also but nothing can turn it transparent. What am I missing? Thanks.
Me too having this issue. Anybody have any thoughts? Thanks.
Please copy the following code into your mainactivity. From this link: https://learnpainless.com/android/material/make-fully-android-transparent-status-bar
@Override
protected void onCreate(Bundle savedInstanceState) {
...
//make translucent statusBar on kitkat devices
if (Build.VERSION.SDK_INT >= 19 && Build.VERSION.SDK_INT < 21) {
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, true);
}
if (Build.VERSION.SDK_INT >= 19) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
//make fully Android Transparent Status bar
if (Build.VERSION.SDK_INT >= 21) {
setWindowFlag(this, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, false);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
}
public static void setWindowFlag(Activity activity, final int bits, boolean on) {
Window win = activity.getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
if (on) {
winParams.flags |= bits;
} else {
winParams.flags &= ~bits;
}
win.setAttributes(winParams);
}