0

ManinActivity.java

public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {

   // requestWindowFeature(Window.FEATURE_NO_TITLE);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
}

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>

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

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

I tried

requestWindowFeature(Window.FEATURE_NO_TITLE); 

feature but it just won't work ! i don't able to find out why.

but when i use

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.NoActionBar">

it just worked !!! but i don't want to use Theme can i do it pragmatically ?

2 Answers 2

3

There are two ways to do that

  1. Set below lines to your styles.xml

    <item name="windowActionBar">false</item>
    

Or

  1. Set below lines in your ActionBarActivity file.

    getSupportActionBar().hide();
    
Sign up to request clarification or add additional context in comments.

Comments

0
@Override
protected void onCreate(Bundle savedInstanceState) {
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.