Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8875319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:56:56+00:00 2026-06-14T18:56:56+00:00

I am showing a menu item in the action bar. I would like to

  • 0

I am showing a menu item in the action bar. I would like to set a background for this item. I would prefer not to use an icon because otherwise I cannot use strings.xml for localization (I am showing some text in this particular menu item, that will get translated in several languages.).

Most of answers here suggest to use icons. The icon of course would cover the text, and if I try android:background instead of android:icon it just won’t show anything.

So basically I want to customize the menu item in the actionbar with a custom image but at the same time be able to write something on it (pull some strings). Is there a way to this in xml?

P.S. I am using Theme.Holo.Light.DarkActionBar but I already changed the background of the actionbar.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:56:57+00:00Added an answer on June 14, 2026 at 6:56 pm

    Create an xml file per each icon you wan to show in the action bar in the ‘drawable’ directory like the one below:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
        <item android:drawable="@drawable/menuitem_bk"/>
        <item android:drawable="@drawable/icon_one"/>      
    </layer-list>
    

    Drawable icon_one is just the icon with a transparent background and ‘menuitem_bk’ will be a drawable defined as follows:

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle" >
        <size
            android:height="36dp"
            android:width="36dp" />
        <solid android:color="@color/action_bar_items_bk_color" />
    </shape>
    

    You will have to create four of these, one in each drawable directory (xhdpi, hdpi, mdpi and ldpi). The size of the shape will be different according to the directory:

    • xhdpi -> 48×48 hdpi -> 36×36 mdpi -> 24×24 ldpi -> 18×18

    (Acording to this: http://developer.android.com/guide/practices/ui_guidelines/icon_design_action_bar.html )

    And you got your ActionBar icons with background.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this code in my menu.xml: <item android:id=@+id/physics android:icon=@drawable/ic_action_*** android:title=@string/physics android:orderInCategory=2 android:showAsAction=always/> Now
I have some trouble showing/hiding this menu on mouse enter. I'd like the menu
I have a before element showing a > before a menu item. You can
This is my js menu that hide/show menu item on hover... I have menu
Is there some way to use the Menu.AttachToWidget(...) function of a gtk menu item
i have ul li structure like below <ul class=lft_mnu id=menu-main-menu> <li class=menu-item menu-item-type-post_type menu-item-object-page
Hi the search widget in the action bar of my application is not displaying
First, please take a look at this pen showing just the menu + the
I'm trying to build a vertical pop-out menu with pure css. Like this one:
I have a tray icon with a popup menu. I am trying to set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.