Devrath
Devrath

Reputation: 42854

Actionbar is showing menu icons as overflow and not individual icons

What is happening:

  1. I am having two icons in actionbar as menu
  2. My minimum sdk is 8 and max is 21
  3. These icons are displayed in dropdown and not individual icons
  4. Theme i am using is Theme.AppCompat.Light.DarkActionBar
  5. My activity is extending ActionBarActiviy

What i want:

I want to show as individual icons

Menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <item
        android:id="@+id/icnMenuWalletId"
        android:icon="@drawable/wallet"
        android:showAsAction="ifRoom"
        android:title="WALLET">
    </item>
    <item
        android:id="@+id/icnMenuTwoId"
        android:icon="@drawable/notification"
        android:showAsAction="ifRoom"
        android:title="NOTIFICATIONS">
    </item>

</menu>

Styles.xml

<resources>

    <!--
        Base application theme for API 11+. This theme completely replaces
        AppBaseTheme from res/values/styles.xml on API 11+ devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- API 11 theme customizations can go here. -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->


    </style>

     <!-- Application theme. -->
    <style name="AppThemeSplash" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
         <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>

    </style>


</resources>

Upvotes: 2

Views: 206

Answers (3)

Hanish Sharma
Hanish Sharma

Reputation: 869

Try this and make sure you have changed the package name tools:context="com.abc.android.HomeActivityNew" to your package name,hope it will help

<menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        tools:context="com.abc.android.HomeActivityNew" >

        <item
            android:id="@+id/icnMenuWalletId"
            android:icon="@drawable/wallet"
            android:showAsAction="always"
            android:title="WALLET">
        </item>
        <item
            android:id="@+id/icnMenuTwoId"
            android:icon="@drawable/notification"
            android:showAsAction="always"
            android:title="NOTIFICATIONS">
        </item>

    </menu>

Upvotes: 0

droidd
droidd

Reputation: 1371

You have to edit one line in you menu.xml. just edit the line to both the menu items

android:showAsAction="always"

By using this, android will show the menu item always. We normally use ifRoom if menu item is not mandatory to show on actionbar.

Upvotes: 3

Deepzz
Deepzz

Reputation: 4571

Change

android:showAsAction="ifRoom" 

to

android:showAsAction="always"

ifRooom is used to move the items to overflow menu if there is no space for it to accomodate

Upvotes: 2

Related Questions