Tuesday, February 6, 2018

How to hide Title Bar in Android

In Android we can hide the title bar and run our app in full screeb view.

To Do this we will use  requestWindowFeature(Window.FEATURE_NO_TITLE)


The requestWindowFeature(Window.FEATURE_NO_TITLE) method of Activity must be called to hide the title. But, it must be coded before the setContentView method.


  1.  @Override  
  2.     protected void onCreate(Bundle savedInstanceState) {  
  3.         super.onCreate(savedInstanceState);  
  4.           
  5.         requestWindowFeature(Window.FEATURE_NO_TITLE);//will hide the title not the title bar  
  6.           
  7.         setContentView(R.layout.activity_main);  
  8.         
  9.     }  
  10. }  

he setFlags() method of Window class is used to display content in full 
screen mode. You need  to pass the 
WindowManager.LayoutParams.FLAG_FULLSCREEN 
constant in the setFlags method.

  1. equestWindowFeature(Window.FEATURE_NO_TITLE);  
  2.     //code that displays the content in full screen mode  
  3.     this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
  4.                 WindowManager.LayoutParams.FLAG_FULLSCREEN);//int flag, int mask  
  5.       
  6.     setContentView(R.layout.activity_main);  
  7.     




1 comment:

  1. Hi,
    Thanks for sharing the information with us it was very informative. Hangup.in

    ReplyDelete