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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:34:36+00:00 2026-06-08T11:34:36+00:00

I have an ImageButton with a background image that has some transparency. By default,

  • 0

I have an ImageButton with a background image that has some transparency. By default, the button gets a grey background where the transparency pixels are – due to the Holo.Light theme. I tried setting the background color of the button to transparent via the setBackgroundColor(Color.TRANSPARENT) method. That works just fine and does what I need except now my button no longer has the light blue color when focused/pressed and looks rather flat (no borders around it, so it looks like an image).

I googled and saw that you can assign selectors as explained here but that would mean that I have to specify an image per button state and I don’t want to do that. I want to inherit the focuses/pressed colors from the theme but overwrite the normal button background (when not pressed/focused) to transparent instead of grey. How can I achieve that?? Please provide a working example as I have tried many different combinations with no success.

Edit
Thank you all for helping. I figured out how to make this work without having to recreate the same image with the focused and pressed states for each button!

Here is my solution:

My button is defined as:

<ImageButton
            android:id="@+id/ImageButton05"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:background="@drawable/button" />

And my background XML file (titled button.xml) is defined as follows:

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

    <item android:state_pressed="true">
        <layer-list>
            <item android:drawable="@drawable/btn_default_pressed_holo_light"></item>
            <item android:drawable="@drawable/network_wifi"></item>
        </layer-list>
    </item>
    <item android:state_focused="true">
        <layer-list>
            <item android:drawable="@drawable/btn_default_focused_holo_light"></item>
            <item android:drawable="@drawable/network_wifi"></item>
        </layer-list>
    </item>
    <item android:state_hovered="true">
        <layer-list>
            <item android:drawable="@drawable/btn_default_focused_holo_light"></item>
            <item android:drawable="@drawable/network_wifi"></item>
        </layer-list>
    </item>
    <item>
        <layer-list>
            <item android:drawable="@drawable/btn_default_normal_holo_light"></item>
            <item android:drawable="@drawable/network_wifi"></item>
        </layer-list>
    </item>
</selector>
  • 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-08T11:34:37+00:00Added an answer on June 8, 2026 at 11:34 am

    I want to inherit the focuses/pressed colors from the theme but overwrite the normal button background (when not pressed/focused) to transparent instead of grey. How can I achieve that??

    AFAIK you can’t because the focus/pressed colors are built in to the same image resources that contain the grey background.

    If you want to keep the system focus/pressed but remove the background you’ll have to grab a copy of the image resources (which can be found in your SDK at /sdkroot/platforms/[version]/data/res/drawable-hdpi replace [version] with whatever api level you are after. And if needbe replace hdpi with another density) and edit out the grey button from them with a photo editor. Then make a selector that references your modified images and set that as the background for your button.

    EDIT:
    Here are the default holo button images for focused and pressed

    focused

    pressed

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

Sidebar

Related Questions

I have a imagebutton with a image source with transparency, but the background color
I'm trying to create a transparent (no button background) ImageButton that has a custom
I have a gridview which has an asp image-button for deleting a row. I
I want a button that Displays an image with NO border, NO background, NO
I have follow this post to make ImageButton in android android image button The
I have an ImageButton and I'd like to remove the ugly (IMHO) background that
i have created an image button in my xml <Button android:layout_height=wrap_content android:id=@+id/send android:layout_width=50dip android:background=@drawable/button_back>
I have an image button with a background image .png of a circle. I
I have a layout that has a listview and imagebutton: <?xml version=1.0 encoding=utf-8?> <RelativeLayout
Since a Button can have a background image and also text, what's the point

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.