Android Activity without ActionBar
Haha, I have been stuck at that point a while ago as well, so I am glad I can help you out with a solution, that worked for me at least :)
What you want to do is define a new style within values/styles.xml so it looks like this
<resources>
<style name = "AppTheme" parent = "android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name = "NoActionBar" parent = "@android:style/Theme.Holo.Light">
<item name = "android:windowActionBar">false</item>
<item name = "android:windowNoTitle">true</item>
</style>
</resources>
Only the NoActionBar style is intresting for you. At last you have to set is as your application's theme in the AndroidManifest.xml so it looks like this
<application
android:allowBackup = "true"
android:icon = "@drawable/ic_launcher"
android:label = "@string/app_name"
android:theme = "@style/NoActionBar" <!--This is the important line-->
>
<activity
[...]
I hope this helps, if not, let me know.
There are multiple ways of doing this.
1) Change the theme in Android Manifest
Below the Application element, you will find theme tag. Replace it with this one -
android:theme="@android:style/Theme.NoTitleBar"
If you are using AppCompat, use @android:style/Theme.AppCompat.NoActionBar
.
This will set the theme for all activities. If you don't need the action bar in a specific acitivity, then set the theme in the activity container, ie
<activity android:theme="@android:style/Theme.NoTitleBar" ...>
You may also set android:theme="@android:style/Theme.NoTitleBar"
theme in the styles and use it later on.
2) Create a Custom Theme
Add this in res/values/styles.xml
<style name="NoActionBar" parent="@android:style/Theme.Holo.Light">
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
and then set it as your activity's theme in Manifest:
<activity android:theme="@style/NoActionBar" ... />
3) Dynamically Remove the Action Bar
Put this code in the onCreate
method before setting content view -
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getActionBar().hide();
If you are using the support library use getSupportActionBar()
.
If you're using AppCompat
, declare your activity in AndroidManifest.xml
as follows:
<activity
android:name=".SomeActivity"
...
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />