0

I need to create application wihtout actionbar. I will try to explain how I create application(maybe I am missing some steps).

1.I am intentionally not choosing "Holo Light with Dark Action Bar" option. I thought this make application without action bar. enter image description here 2.Leaving next page as default: enter image description here 3.Leaving next page as default: enter image description here 4.On the next page, it becomes interesting. Blank Activity's description says that it creates a new blank activity an action bar. On Empty Activity's description: Creates a new empty activity. So I choose Empty activity

enter image description here

5.Leaving next page as default.

Result:As usually, application was created with ActionBar.

enter image description here enter image description here

Tried this solution:getActionBar().hide();. In this solution, ActionBar is hiden after some milliseconds.

Tried to use android:theme="@android:style/Theme.NoTitleBar" in AndroidManifest.xml->application tag. But in this solution, application uses old theme.

enter image description here

My question: how to create Android application without ActionBar using new theme and leaving StatusBar enabled?

PS. I remember, about one year ago, in Eclipse, applications were created without ActionBar. Then we added it manually

Community
  • 1
  • 1
Joe Rakhimov
  • 4,713
  • 9
  • 51
  • 109

4 Answers4

1

Put this right after super.onCreate(savedInstanceState); in the onCreate method of your activity(s):

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

Make sure you put this BEFORE this.setContentView(R.layout.activity_example); to avoid crashes

crejaud
  • 65
  • 3
1

When your project is started you can use public activity extends Activity instead of using ActionBarActivity this will also remove the action bar or there is another way

    <android:theme="@android:style/Theme.NoTitleBar">

or you can see these links they might help

How to hide action bar before activity is created, and then show it again?

Remove android default action bar

Community
  • 1
  • 1
Umair
  • 6,366
  • 15
  • 42
  • 50
  • As I described in question ("Tried to use android:theme="@android:style/Theme.NoTitleBar" in AndroidManifest.xml->application tag. But in this solution, application uses old theme."), this makes App use old theme – Joe Rakhimov Aug 21 '14 at 07:08
  • picpaste.com/Screenshot_2014-08-21-11-58-43-AA6TRgPY.png – Joe Rakhimov Aug 21 '14 at 07:14
  • @JoeRichard you want your app to like this pic right without action bar ? – Umair Aug 21 '14 at 07:20
  • @JoeRichard I applied the code given in first link in my answer and there was not action bar. try this public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); getActionBar().hide(); setContentView(R.layout.splash); – Umair Aug 21 '14 at 07:21
  • you misunderstood me. I dont need for old theme(as shown in screenshot). How to remove ActionBar at the same time using new theme like this? – Joe Rakhimov Aug 21 '14 at 07:25
  • @JoeRichard I thought you were asking for removing the actionBar from your activity. Sorry mate then you have to keep searching but if you want to remove action bar from your app then I have written the code above. – Umair Aug 21 '14 at 07:31
  • Sorry, buddy. I agree with you. I should have state question correctly. Thank you for your valuable time – Joe Rakhimov Aug 21 '14 at 07:40
0

Refer this code and change as per your requirement:

Update :

styles.xml :

 <style name="FullscreenTheme" parent="android:Theme.Holo">
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:windowBackground">@null</item>
    <item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
    <item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>

<style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar">
    <item name="android:background">@color/black_overlay</item>
</style>

These will remove actionbar and keeps your theme as it is .

Note : Here i have tested using Theme.Holo . you can use yours.

AndroidManifest.xml

  <activity
        android:name=".GridViewExample"
        android:theme="@style/FullscreenTheme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

It gives you activity without ActionBar. Hope this solves your problem.

Deep Shah
  • 1,334
  • 3
  • 20
  • 41
  • As I described in question ("Tried to use android:theme="@android:style/Theme.NoTitleBar" in AndroidManifest.xml->application tag. But in this solution, application uses old theme."), this makes App use old theme – Joe Rakhimov Aug 21 '14 at 07:04
0

You can do it programatically:

public class ActivityName extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // remove title
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);
    }
}

Or you can do it via your AndroidManifest.xml file:

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

EDIT :

If your app uses any other theme use corresponding theme name E.g. For White theme @android:style/Theme.Holo.Light.NoActionBar.Fullscreen

Jamil
  • 5,457
  • 4
  • 26
  • 29
  • this method is working. because of this:android:theme="@android:style/Theme.NoTitleBar.Fullscreen" app will use old theme. How to use this method by using new theme? is it possible? – Joe Rakhimov Aug 21 '14 at 07:22
  • If your app uses any other theme use corresponding theme name E.g. For White theme @android:style/Theme.Holo.Light.NoActionBar.Fullscreen – Jamil Aug 21 '14 at 07:40
  • Tried like this android:theme="@style/Theme.AppCompat.Light.NoActionBar.Fullscreen". It is giving this error: error: Error: No resource found that matches the given name (at 'theme' with value '@style/ Theme.AppCompat.Light.NoActionBar.Fullscreen'). – Joe Rakhimov Aug 21 '14 at 07:59
  • @android:style/Theme.Holo.Light.NoActionBar.Fullscreen requires API13+. I need API9+ – Joe Rakhimov Aug 21 '14 at 08:01