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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:39:03+00:00 2026-06-18T15:39:03+00:00

I would like to make a button that is fill with more than 3

  • 0

I would like to make a button that is fill with more than 3 colors, say 7 color rainbow, starting from left = red to right = purple.

But I find that the following code could only meet for 3 colors.

Question:

Is there a way to generate a rainbow gradient? I have on my hand a Rainbow.png, would that be used? Thanks!!

Current code:

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

    <item android:state_pressed="true" >         
        ...   
    </item>

    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android"> 
            <stroke android:width="0dp" android:color="@color/black" />
            <gradient
                android:startColor="@color/red"
                android:centerColor="@color/green"
                android:endColor="@color/purple"
                android:angle="0" />
            <padding android:left="5dp" android:top="2dp" 
                android:right="5dp" android:bottom="2dp" /> 
            <corners android:radius="0dp" /> 
        </shape>
    </item>

</selector>

Answer:

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

    <item android:state_pressed="true" >         
        <shape xmlns:android="http://schemas.android.com/apk/res/android"> 
            <stroke android:width="0dp" android:color="@color/black" />
            <solid android:color="@color/grey"/>
            <padding android:left="5dp" android:top="2dp" 
                android:right="5dp" android:bottom="2dp" /> 
            <corners android:radius="0dp" /> 
        </shape>    
    </item>

    <item android:drawable="@drawable/rainbow" >
        <shape xmlns:android="http://schemas.android.com/apk/res/android"> 

            <padding android:left="5dp" android:top="2dp" 
                android:right="5dp" android:bottom="2dp" /> 
            <corners android:radius="0dp" /> 
        </shape>
    </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-18T15:39:04+00:00Added an answer on June 18, 2026 at 3:39 pm

    Android has the 9-patch system built in to handle complicated graphics, which is similar in style to how some website backgrounds are drawn.

    Android also has it’s own 9-patch creator bundled with the sdk, so it’s easy enough to edit your png file, then apply the 9-patch to the button.

    This will allow you to use your png, and it’ll resize according to the stretchable area of your graphic that you define to resize as your button resizes

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

Sidebar

Related Questions

I would like to make a button on my website that automatically logs me
I would like to make a button that allows you to go to the
I would like to make register button, but when people click on it. A
I would like to make a button with large hover picture on top of
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to make a function that takes in a list of integers
I have a layout file containing a listview that I would like to fill
In Excel I have a date field. I would like to make a button
I would like to make a C# application that displays a message when the
I'm currently using TinyMCE and would like to add a custom button that works

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.