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 7856565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:44:54+00:00 2026-06-02T20:44:54+00:00

in my current project I’m building an App with API 10 which should look

  • 0

in my current project I’m building an App with API 10 which should look like an ICS App.
Since my GUI is not very complex I can build this all manually, but I have some problems with button states.

I googled a lot and found nothing that would work for me so I would appreciate any help 😉

I designed an action bar with google ICS stock icons. When for example someone touches the search-loupe-icon, which has an 8dp padding around it, it’s background color should change to a defined highlight-color-value.

So now you would suggest probably a selector drawable. But my case is: I have an icon-drawable which has an background-color, which I want to change. I dont want to change the icon, so since I cant change the backgroundcolor from a selector-xml this doesn’t work.
(I thought I can setup multiple drawable-xml with my icon static bg colors so that I could refer with one selector to those different colored icons, but since a shape-drawable-xml cannot have a source and an bitmap-drawable-xml cannot have a background color, this is no sollution.)

If I try to change the background color in my onclick-listener (also tried onTouch) with:

ImageButton searchIcon = (ImageButton) findViewById(R.id.upper_actionbar_icon_search);
            searchIcon.setBackgroundColor(R.color.android_ics_blue_light);

The Icon gets a dark grey bg color. This is also true for any other color altough nothing lies on top of the ImageButton. I also tried an ImageView.

So could someone explain to my please how the hell I can define a highlighted bg color-image without any hacks (default-gone image that lies above the icon and is set visible onclick).
Thanks so much!!

  • 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-02T20:44:55+00:00Added an answer on June 2, 2026 at 8:44 pm

    Okay the solution is simple.

    Write yourself a drawable selector which looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    

    <item android:state_selected="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/android_ics_blue_light"/>
        </shape>
    </item>
    
    
    <item android:state_pressed="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/android_ics_blue_light"/>
        </shape>
    </item>
    
     <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/light_grey"/>
        </shape>
    </item>
    

    Within your ImageButton code define your icon as src and your new drawable as background, like this:

    <ImageButton
                    <!-- ... -->
                    android:src="@drawable/icon_search" 
                    android:background="@drawable/actionbar_ontouch"
    
                    />
    

    Works like a charm!

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

Sidebar

Related Questions

In my current project we are testing our ASP.NET GUI using WatiN and Mbunit
My current project for work involves developing a SharePoint 2007 WebPart which will be
My current project is in rails 2.3.5 which uses restful authentication. I am moving
Our current project does not use Hibernate (for various reasons) and we are using
On my current project I am in the process of building tablet and mobile
For my current project I would like to test out the application on a
My current project uses JPA and HSQLDB. I would like to persist multiple related
My current project is created for API Level 4 and I use custom implementation
For a current project I am embedding a mobile site into an iOS app.
In our current project I am using a generic interface iService which is inherited

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.