Thursday, June 28, 2012

Disable Title Bar or Full Screen View in Android

Today i learn how to disable Notification bar (Battery, Network Status info Bar ) Top of the Screen.

and how can we set Full Screen View to Our Application Screen.

Just a pretty simple code see below..

//to disable notification bar (Top Bar)
  requestWindowFeature(Window.FEATURE_NO_TITLE);
     
 //to set full screen view
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                       WindowManager.LayoutParams.FLAG_FULLSCREEN);

Note: Above code put before loading the main view or we can say before this line
setContentView(R.layout.main);

also i made simple app to achieve this if need then have look on it.

-------------------------------------------
App Name: DisableTitleBar
Package Name: com.rdc
Android SDK: Android SDK 2.3.3 / API 10
Default Activity Name: MyActivity
-------------------------------------------
so here is the code 

MyActivity.java

package com.rdc;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class MyActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
        
     //to disable notification bar (Top Bar)
     requestWindowFeature(Window.FEATURE_NO_TITLE);
        
     //to set full screen view
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
     //make sure code should be before calling below method
     setContentView(R.layout.main);
  }
}

main.xml

 
 
  
 



AndroidManifest.xml




 
  
  
  
  
 




The output will be like this..



I'd love to hear your thoughts!

No comments:

Post a Comment