2013-08-21 34 views
1

我需要隱藏Os 4.0+中的導航欄(帶有後退按鈕的導航欄)。我試圖做到這一點,而不訴諸於代碼。這是我styles.xml資源文件:無法隱藏僅使用xml樣式的導航欄

 <?xml version="1.0" encoding="utf-8"?> 
     <resources> 
      <style name="AppBaseTheme" parent="@android:style/Theme.Holo.Light"> 
      </style> 


      <style name="AppTheme" parent="AppBaseTheme"> 
      </style> 


      <style name="FullScreen" parent="@android:style/Theme.NoTitleBar.Fullscreen"> 
      </style> 

     </resources> 

這是我的清單:

 <?xml version="1.0" encoding="utf-8"?> 
     <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
      package="xxx.xxx.xxx.xxx" 
      android:versionCode="1" 
      android:versionName="1.0" > 

      <uses-sdk 
       android:minSdkVersion="11" 
       android:targetSdkVersion="17" /> 

      <application 
       android:allowBackup="true" 
       android:icon="@drawable/ic_launcher" 
       android:label="@string/app_name" 
       android:theme="@style/AppTheme" > 
       <activity 
        android:name="xxx.xxx.xxx.xxx.MainActivity" 
        android:configChanges="orientation|keyboardHidden|screenSize" 
        android:label="@string/app_name" 
        android:theme="@style/FullScreen" > 
        <intent-filter> 
         <action android:name="android.intent.action.MAIN" /> 
         <category android:name="android.intent.category.LAUNCHER" /> 
        </intent-filter> 
       </activity> 
      </application> 

     </manifest> 

我正在嘗試設置全息光作爲全球主題,只爲主要活動的全屏的主題。上述文件不工作,我發現的唯一辦法就是做這在我活動的onCreate:

mainView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); 

這有什麼錯與XML的唯一途徑? PS:我知道這在3.x中是不可能的,但是我在4.1模擬器中測試了這個,我可以用setSystemUiVisibility來隱藏導航欄。

+0

相似問題:http://stackoverflow.com/questions/9926767/is-there-a-way-to-hide-the-system-navigation-bar-in-android-ics –

回答

1

最後似乎這是不可能的只使用XML。甚至使用代碼,在某些平板電腦(如Samsung Galaxy Tab)中,不可能隱藏導航欄。