禁用横屏全屏显示

3

在横屏模式下禁用全屏模式是否可行?

如果不行,是否有任何解决方法?


除非您明确指定,否则它不应该是全屏! - iTurki
1个回答

2
将此代码放在onCreate()方法中。
 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);
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接