Monday, February 4, 2013

Remove title bar through XML and programmatically

Some times we require title bar but for some activity there is no need of title bar .

There is  two way to remove title bar in android
  1. Modifying manifest i.e XML.
  2. By programmatically.
 1. Modifying manifest i.e XML:

<activity android:name=".ActivityName"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar">
</activity>

 2. By programmatically.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);
}


If you want NoTitleBar for application then use following:

 <application
        android:allowBackup="true"
       android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/android:Theme.Black.NoTitleBar" >
      
        <activity android:name=".ActivityName" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
 </application>


No comments:

Post a Comment