【问题标题】:Popup window makes notification bar visible on fullscreen activity in android弹出窗口使通知栏在 android 的全屏活动中可见
【发布时间】:2020-11-13 22:18:12
【问题描述】:

我有一个全屏活动并通过以下代码将其设置为全屏

private void setFullScreenFocus() {
    getWindow().getDecorView()
            .setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}

我已经实现了一个弹出窗口对话框,但是当它显示时,它使状态栏和导航栏可见。如何避免?

下面是弹窗代码

PopupWindow seasonEpisodePopUpWindow;
LayoutInflater inflater = (LayoutInflater) anchorView.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (seasonEpisodeView == null)
        seasonEpisodeView = inflater.inflate(R.layout.player_seasons_episode_list, null);
if (!seasonEpisodePopUpWindow.isShowing()) {
            seasonEpisodePopUpWindow.showAtLocation(anchorView, Gravity.BOTTOM, viewLocation[0], height);
            appCMSPlayVideoFragment.setPreviousNextVisibility(false);
        }

【问题讨论】:

  • 您可以查看此链接以获取您的代码stackoverflow.com/questions/36554599/…
  • 您是否在创建对话框时发送此活动对象?像new AlertDialog(this) 什么的?
  • @RahulKumar popupwindown 不是警报对话框

标签: android android-activity android-popupwindow


【解决方案1】:

对我来说,该问题仅在 Android 5.0 上出现,并且仅在弹出窗口为全屏窗口时出现。我找到了以下解决方法,而不是:

mPopupWindow.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
mPopupWindow.setHeight(WindowManager.LayoutParams.MATCH_PARENT);

我写道:

DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
mPopupWindow.setWidth(displayMetrics.widthPixels);
mPopupWindow.setHeight(displayMetrics.heightPixels);

而且效果惊人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多