仅在横向模式下使Android应用程序全屏

时间:2015-10-26 20:20:21

标签: android android-layout screen-orientation android-fullscreen

通常情况下,要在我onCreate setContentView之前requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 内全屏显示我的应用

setContentView

但我有一种情况需要在横向方向启用全屏 - 但不是纵向。但是,如下所示会引发与@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if(newConfig.orientation==Configuration.ORIENTATION_PORTRAIT){ attachViewPager(); }else{ requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); detachViewPager(); } } 有关的异常。那么我该怎么做呢?

a.site_id = b.site_id

1 个答案:

答案 0 :(得分:0)

尝试这可能它会帮助你

if (Build.VERSION.SDK_INT < 16) {
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
}