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

  • Home
  • SEARCH
  • 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 8496737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:56:09+00:00 2026-06-10T23:56:09+00:00

I would like my Button to draw with a transparent background by default, to

  • 0

I would like my Button to draw with a transparent background by default, to draw with a dark blue background when pressed, and to draw with a light blue background when selected. I set the Button’s background to the below selector, and am calling Button.setSelected(!Button.isSelected()) when the button is clicked. The pressed state works properly, but the Button draws with a transparent background when selected.

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/tranpsshape" /> 
  <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/tranpsshape" /> 
  <item android:state_pressed="true" android:drawable="@drawable/pressedbuttonshape" /> 
  <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/selectedshape" /> 
  <item android:state_enabled="true" android:drawable="@drawable/tranpsshape" /> 
  <item android:state_focused="true" android:drawable="@drawable/tranpsshape" /> 
  <item android:state_selected="true" android:drawable="@drawable/selectedshape" /> 
  <item android:drawable="@drawable/tranpsshape" /> 
</selector>

selectedshape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="#A3DAF2"/>
</shape>

pressedbuttonshape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="#4ABDE8/>
</shape>

tranpsshape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="#00000000"/>

</shape>
  • 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-10T23:56:10+00:00Added an answer on June 10, 2026 at 11:56 pm

    Accordind to documentation

    During each state change, the state list is traversed top to bottom and the first item that matches the current state will be used—the selection is not based on the “best match,” but simply the first item that meets the minimum criteria of the state.

    So you need to place state_selected above state_focused. So your file will look like this

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/tranpsshape" /> 
        <item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/tranpsshape" /> 
        <item android:state_pressed="true" android:drawable="@drawable/pressedbuttonshape" /> 
        <item android:state_selected="true" android:drawable="@drawable/selectedshape" />         
        <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/selectedshape" /> 
        <item android:state_enabled="true" android:drawable="@drawable/tranpsshape" /> 
        <item android:state_focused="true" android:drawable="@drawable/tranpsshape" /> 
        <item android:drawable="@drawable/tranpsshape" /> 
    </selector>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like the button on my web page to toggle the visibility of
I would like a button to change a label between being visible and not
I would like a home button on all my actives so they can bring
net website, I would like to add button by which user can view the
I would like to make register button, but when people click on it. A
I would like to handle a button clicked event in a native c++ class.
I would like to put a button on top of a Google Map next
I would like to create a button control that has a Path element as
I would like to have a button in my window such that if I
I would like to create a button in my UIView that when touched spawns

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.