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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:25:34+00:00 2026-05-26T04:25:34+00:00

I tried to change the background color of the toggle button using XML file

  • 0

I tried to change the background color of the toggle button using XML file as white color, but the toggle button is totally damaged. It looks like all the button was covered with white.

There is no indication of ON or OFF on the toggle button when I have changed the color of the toggle button to white. Is there is another way to change the background which will not damage the indication of the toggle button?

<ToggleButton android:id="@+id/togglebutton"
              android:layout_width="100px"
              android:layout_height="46px"
              android:background="#ffffff"
              android:layout_above ="@+id/save"
              android:textOn="DAY"
              android:textOff="NIGHT" />

This is how my XML code look for the toggle button.

  • 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-05-26T04:25:35+00:00Added an answer on May 26, 2026 at 4:25 am

    Yes, there is a way to change the background as you wish, but you have to use a selector like this as background:

    <selector
        xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <item
        android:state_focused="true"
        android:state_pressed="false"
        android:drawable="@drawable/some_image" />
    <item
        android:state_focused="true"
        android:state_pressed="true"
        android:drawable="@drawable/some_other_image" />
    <item
        android:state_focused="false"
        android:state_pressed="false"
        android:drawable="@drawable/some_image1" />
    <item
        android:state_focused="false"
        android:state_pressed="true"
        android:drawable="@drawable/other_image" />
    </selector>
    

    For @Drawable, etc. (you can use a color or make a gradient. Check this for more information about gradients.

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

Sidebar

Related Questions

What is the easiest way to change the background color of a toggle button
I've tried achieving a hover/selected color change for a particular field, but I'm thinking
how to change background color of line highlighting during debug process in Netbeans? Tried
How to change background color of GtkTextView? I tried with normal widget set bg
can I change background color for disabled <h:inputText> ? I've tried to do this
I would like to change the background color of all the rows with value
Although this seems like a simple task, I need to change the background color
I'm trying to change background color of ImageView, but it updates only after I
How can I dynamically change the background color of a button in Tkinter ?
How to change cell background image on click on cell in iphone????I have tried

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.