2017-05-31 38 views
1

我正在創建一個相機應用程序與一些相機設置的彈出菜單。問題是,當我點擊顯示彈出菜單的按鈕時,出現底部導航欄。我已經在網上搜索了一個解決方案,但迄今爲止還沒有爲我工作。導航欄顯示在身臨其境的模式PopupMenu

mChangeSettingsButton.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 

      final PopupMenu changeSettingsPopupMenu = new PopupMenu(Camera2VideoImageActivity.this, mChangeSettingsButton) { 
       @Override 
       public void show() { 

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); 
        super.show(); 

        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE 
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY 
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 
            | View.SYSTEM_UI_FLAG_FULLSCREEN 
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); 


        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); 

       } 


      };changeSettingsPopupMenu.getMenuInflater().inflate(R.menu.change_setting_popup_menu, changeSettingsPopupMenu.getMenu()); 

      SubMenu changeImageResolutionSubMenu = changeSettingsPopupMenu.getMenu().addSubMenu(0, 100, 0, "Set Image Resolution "); 
      SubMenu changeVideoResolutionSubMenu = changeSettingsPopupMenu.getMenu().addSubMenu(0, 101, 0, "Set Video Resolution"); 
      changeSettingsPopupMenu.show(); 
} 

我也有這個在我的主要活動:

@Override 
public void onWindowFocusChanged(boolean hasFocus) { 
    super.onWindowFocusChanged(hasFocus); 
    if (hasFocus) { 
     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 
         | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); 
    } 

<iframe src="https://giphy.com/embed/3oKIPh2W4bEQrGzmqQ" width="272" height="480" frameBorder="0" class="giphy-embed" allowFullScreen></iframe><p><a href="https://giphy.com/gifs/3oKIPh2W4bEQrGzmqQ">via GIPHY</a></p>

GIF發生了什麼: http://gph.is/2rjPdny

編輯: 感謝亞太區首席技術官Matt Gehlot回覆!我嘗試時得到這個。 This didn't work, Click to view image

回答

0

試試這個:

changeSettingsPopupMenu.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); 
     changeSettingsPopupMenu.getWindow().getDecorView().setSystemUiVisibility(getWindow().getDecorView().getSystemUiVisibility()); 
changeSettingsPopupMenu.show(); 
+0

感謝您的答覆!我試過這個,但我得到了「無法解決getWindow()」。請檢查我的編輯原始文章的截圖。 –