MaterialViewPager icon indicating copy to clipboard operation
MaterialViewPager copied to clipboard

Status bar not transparent

Open srpanchal opened this issue 9 years ago • 2 comments

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.

srpanchal avatar Oct 16 '16 16:10 srpanchal

Me too having this issue. Anybody have any thoughts? Thanks.

shahimclt avatar Jun 15 '17 17:06 shahimclt

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);
}

Winghin2517 avatar Jun 29 '18 17:06 Winghin2517