gpt4 book ai didi

android - 溢出菜单单击禁用沉浸模式 - Android 4.4 Kitkat

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:02:42 24 4
gpt4 key购买 nike

任何人都知道这是一个错误还是应该这样做。在使用 KitKat 的沉浸模式时单击溢出图标时,它会禁用沉浸模式。还有其他人遇到这个问题吗?

Google 的完整代码 - Here

public void toggleHideyBar() {

// The UI options currently enabled are represented by a bitfield.
// getSystemUiVisibility() gives us that bitfield.
int uiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility();
int newUiOptions = uiOptions;
boolean isImmersiveModeEnabled =
((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
if (isImmersiveModeEnabled) {
Log.i(TAG, "Turning immersive mode mode off. ");
} else {
Log.i(TAG, "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;
}

getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
}

最佳答案

在 K 中,溢出菜单是一个获得焦点的单独窗口,因此驱动当前系统 UI 标志。

但是,只有在隐藏状态栏时尝试显示操作栏时才会出现这种情况,即 discouraged .对于操作栏之外的上下文菜单,您可以使用 PopupWindow相反(使用 PopupWindow,您可以根据需要自行设置系统 UI 标志)。

关于android - 溢出菜单单击禁用沉浸模式 - Android 4.4 Kitkat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20365415/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com