1. 程式人生 > >android 隱藏導航欄 狀態列 標題欄

android 隱藏導航欄 狀態列 標題欄

1. 隱藏當前Activity標題欄

    在當前Activity中呼叫:this.requestWindowFeature(Window.FEATURE_NO_TITLE);

2. 隱藏當前Activity狀態列(Status Bar)

2.1 Android 4.0 and Lower

  1. publicclass MainActivity extends Activity {  
  2.     @Override
  3.     protectedvoid onCreate(Bundle savedInstanceState) {  
  4.         super.onCreate(savedInstanceState);  
  5.         // If the Android version is lower than Jellybean, use this call to hide
  6.         // the status bar.
  7.         if (Build.VERSION.SDK_INT < 16) {  
  8.             getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
  9.                     WindowManager.LayoutParams.FLAG_FULLSCREEN);  
  10.         }  
  11.         setContentView(R.layout.activity_main);  
  12.     }  
  13.     ...  
  14. }  

2.2 Android 4.1 and Higher

  1. View decorView = getWindow().getDecorView();  
  2. // Hide the status bar.
  3. int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;  
  4. decorView.setSystemUiVisibility(uiOptions);  
  5. // Remember that you should never show the action bar if the
  6. // status bar is hidden, so hide that too if necessary.
  7. ActionBar actionBar = getActionBar();  
  8. actionBar.hide();  

3. 隱藏當前Activity介面的導航欄(NavigationBar)

    在Android4.0及以後版本中,可通過以下方法隱藏NavigationBar

  1. View decorView = getWindow().getDecorView();  
  2. // Hide both the navigation bar and the status bar.
  3. // SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
  4. // a general rule, you should design your app to hide the status bar whenever you
  5. // hide the navigation bar.
  6. int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION  
  7.               | View.SYSTEM_UI_FLAG_FULLSCREEN;  
  8. decorView.setSystemUiVisibility(uiOptions);  


4. 隱藏所有Activity介面的標題欄

 修改AndroidManifest.xml 
 在application 標籤中新增a
    android:theme="@android:style/Theme.NoTitleBar"

5. 隱藏所有Activity介面的TitleBar 和StatusBar 

  修改AndroidManifest.xml 
  在application 標籤中新增 

  Android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

http://blog.csdn.net/myarrow/article/details/25606653(轉)
http://blog.csdn.net/myarrow/article/details/25606653(轉)