我正在尝试实现全屏模式,但对于Android 4.4及更高版本,它会在那里显示一个空白区域:
在沉浸式模式之前(全屏)
和AFTER的toggleFullScreen
(假);
如你所见,它不会删除它.这是我用来切换它的代码:
public void toggleFullscreen(boolean fs) { if (Build.VERSION.SDK_INT >= 11) { // The UI options currently enabled are represented by a bitfield. // getSystemUiVisibility() gives us that bitfield. int uiOptions = this.getWindow().getDecorView().getSystemUiVisibility(); int newUiOptions = uiOptions; boolean isImmersiveModeEnabled = ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions); if (isImmersiveModeEnabled) { Log.i(getPackageName(), "Turning immersive mode mode off. "); } else { Log.i(getPackageName(), "Turning immersive mode mode on."); } // Navigation bar hiding: Backwards compatible to ICS. if (Build.VERSION.SDK_INT >= 14) { newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; } // Status bar hiding: Backwards compatible to Jellybean if (Build.VERSION.SDK_INT >= 16) { newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN; } // Immersive mode: Backward compatible to KitKat. // Note that this flag doesn't do anything by itself, it only augments the behavior // of HIDE_NAVIGATION and FLAG_FULLSCREEN. For the purposes of this sample // all three flags are being toggled together. // Note that there are two immersive mode UI flags, one of which is referred to as "sticky". // Sticky immersive mode differs in that it makes the navigation and status bars // semi-transparent, and the UI flag does not get cleared when the user interacts with // the screen. if (Build.VERSION.SDK_INT >= 18) { newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } getWindow().getDecorView().setSystemUiVisibility(newUiOptions); } else { // for android pre 11 WindowManager.LayoutParams attrs = getWindow().getAttributes(); if (fs) { attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; } else { attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN; } this.getWindow().setAttributes(attrs); } try { // hide actionbar if (this instanceof AppCompatActivity) { if (fs) getSupportActionBar().hide(); else getSupportActionBar().show(); } else if (Build.VERSION.SDK_INT >= 11) { if (fs) getActionBar().hide(); else getActionBar().show(); } } catch (Exception e) { e.printStackTrace(); } }
Boris Treukh.. 36
请检查android:fitsSystemWindows="true"
您的布局中没有.
至少它解决了我的情况 - 我在FrameLayout上有适合的SystemWindows.
请检查android:fitsSystemWindows="true"
您的布局中没有.
至少它解决了我的情况 - 我在FrameLayout上有适合的SystemWindows.
我是新来的,所以我无法发表评论,但想添加让我对上述解决方案感到沮丧的东西.我一直在检查我的活动及其碎片android:fitsSystemWindows="true"
,它绝对不存在,但我仍然在底部留有空隙!我疯了!修复这个简单的事情并不难!
事实证明它也出现在我添加的导航抽屉中......所以一定要检查所有的XML!