user2302718
user2302718

Reputation: 71

How to remove the menu from an action bar (java)

I'm new to android development and wanted to make a tabbed application, so I started with google's file form the documentation and I would like to remove the most above part of the action bar (where the logo and the app name stands). I've tried styling it like this:

<resources>
<style name="ThemeHoloWithActionBar" parent="android:Theme.Holo.Light.DarkActionBar">
    <item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>

    <item name="android:actionBarSize">50dip</item>
</style>

<style name="ActionBarTabStyle" parent="@android:style/Widget.Holo.ActionBar.TabView">
    <item name="android:minHeight">50dip</item>
</style>

hoping that it would push the size of the other bar to 0 but it didn't work.

Edit: when using:

<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>

I Can't get the error formatted correctly so I uploaded an image :

https://i.sstatic.net/3WMw0.jpg

Upvotes: 0

Views: 281

Answers (2)

Xcihnegn
Xcihnegn

Reputation: 11597

To remove actionbar, you need add:

<item name="android:windowNoTitle">true</item> 
<item name="windowActionBar">false</item> 

to your AppTheme style file, after remove, then you can not use default actionbar to add tabs.

If you still want to use tabs, then you have to use SlidingTabLayout to make a custom ViewPager title strip. There is Android sample project SlidingTabsBasic, which show detail how to make custom tabs.

Upvotes: 0

GabrielAtan
GabrielAtan

Reputation: 410

If you don’t need the action bar, you can remove it from your entire app or from individual activities. This is appropriate for apps that never used the options menu or for apps in which the action bar doesn’t meet design needs (such as games). You can remove the action bar using a theme such as Theme.Holo.NoActionBar or Theme.DeviceDefault.NoActionBar.

in style.xml add this:

<resources>
    <style name="NoActionBar" parent="@android:style/Theme.Holo.NoActionBar">
        <!-- Your style here -->
    </style>
</resources>

in AndroidManifest.xml add this:

<!-- [...] -->
    <application android:name="@style/NoActionBar"
<!-- [...] -->

or try with this:

<!-- [...] -->
    <application android:theme="@style/NoActionBar">
<!-- [...] -->

Upvotes: 2

Related Questions