Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Full screen in landscape

Is it possible to disable full screen mode in Landscape ?

If not, is any workaround?

like image 305
robert Avatar asked Jan 01 '26 21:01

robert


1 Answers

Put This code in onCreate() Method.

 if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)                 
 {
       //To re-enable full screen:

       getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
       getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);       
}
else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) 
{
       //To disable full screen:

       getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
       getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
like image 184
Chirag Avatar answered Jan 03 '26 10:01

Chirag



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!