2017-09-04 24 views
-3

我試圖使用下面的代碼刪除標題欄。但它不起作用,它仍然顯示標題欄。如何刪除標題欄並以全屏模式運行?

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); 
    setContentView(R.layout.activity_main); 
} 

我甚至試圖改變在mainfest文件主題定爲follows.But應用程序停止工作,說:「不幸的是對myApp已停止工作」。

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

+0

什麼日誌說? – Isaac

回答

1

調用的setContentView之前做到這一點()

requestWindowFeature(Window.FEATURE_NO_TITLE); 
getWindow().requestFeature(Window.FEATURE_ACTION_BAR); 
if (getSupportActionBar() != null) 
    getSupportActionBar().hide(); 
//Remove notification bar 
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);