2016-05-28 21 views
0

我與全屏幕應用程序,但是當我顯示一個彈出窗口,我失去了整個屏幕的行爲,我的臉頰我的應用程序只有在我失去了全屏彈出,全屏幕的Android應用程序永久

這是我的

public void call(Activity activity) { 
    if(Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api 
     View v = activity.getWindow().getDecorView(); 
     v.setSystemUiVisibility(View.GONE); 
    } else if(Build.VERSION.SDK_INT >= 19) { 
     //for new api versions. 
     View decorView = activity.getWindow().getDecorView(); 
     int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; 
     decorView.setSystemUiVisibility(uiOptions); 
    } 
} 

我google一下,我在這post發現「只有效果,當你從調用它的觀點是可見

所以有一個解決方案:全屏幕的方法?

回答

0

試試這個:

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
    WindowManager.LayoutParams.FLAG_FULLSCREEN); 

    setContentView(R.layout.activity_main); 

} 

UPDATE: 試試這個:

public void open(View view){ 

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); 
    alertDialogBuilder.setMessage("Are you sure,You wanted to make decision"); 



    alertDialogBuilder.setPositiveButton("yes", new DialogInterface.OnClickListener() { 

     @Override 
     public void onClick(DialogInterface arg0, int arg1) { 
      Toast.makeText(MainActivity.this,"You clicked yes button",Toast.LENGTH_LONG).show(); 
     } 
    }); 

    alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() { 
     @Override 
     public void onClick(DialogInterface dialog, int which) { 
      finish(); 
     } 
    }); 

    AlertDialog alertDialog = alertDialogBuilder.create(); 
    alertDialog.show(); 
    alertDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 

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


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

} 
+0

感謝的,但不能正常工作。 – Euphor08

+0

嘗試在AndroidManifest.xml文件中: android:theme =「@ android:style/Theme.NoTitleBar.Fullscreen」 – Icero

+0

老兄我需要隱藏底部欄,當我顯示彈出框時,已經嘗試了stackoverlfow的所有帖子,再次感謝爲你的迴應 – Euphor08

0

你必須使用SYSTEM_UI_FLAG_IMMERSIVE_STICKY針對這種情況,請參見官方documentation瞭解更多詳情

更新

不要忘了在你的manifest.xml這個

<activity android:name=".YourActivity" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
     /> 

補充:

+0

我的函數在**第7行**中已經有了'SYSTEM_UI_FLAG_IMMERSIVE_STICKY',並且當我打開一個彈出窗口時,問題就是全屏丟失,謝謝。 – Euphor08

+0

看到我的更新,也許它會幫助你 –

+0

已經在Manifest文件中有這條線,但它不起作用。 – Euphor08