Tuesday, December 6, 2011

Hiding the Title bar and Status bar in Android

We can hide the title and status bars by 2 ways:

1. Using "AndroidManifest.xml" file:

  • To hide the title bar use the predefined style
    •  android:theme=”@android:style/Theme.NoTitleBar” 
  • To hide the status bar use
    •   android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”

2. Using code in your activity class:

  • @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // hide titlebar of application
        // must be before setting the layout
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // hide statusbar of Android
        // could also be done later
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);
        text = (EditText) findViewById(R.id.EditText01);

    }

No comments:

Post a Comment