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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:04:00+00:00 2026-06-18T16:04:00+00:00

According to what I’ve read, you can use a gradientDrawable and have three colors

  • 0

According to what I’ve read, you can use a gradientDrawable and have three colors set for it, for example:

<gradient startColor="#00FF00" centerColor="#FFFF00" endColor="#FFFFFF"/>

But what if I want more than three colors, and not only that, I want to be able to set where to put each (in weight/percentage)?

Is it possible using the API or should I make my own customized drawable? If I need to make my own customized drawable, how should I do it?

  • 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-18T16:04:02+00:00Added an answer on June 18, 2026 at 4:04 pm

    put this code in your onCreate() method:

    ShapeDrawable.ShaderFactory shaderFactory = new ShapeDrawable.ShaderFactory() {
        @Override
        public Shader resize(int width, int height) {
            LinearGradient linearGradient = new LinearGradient(0, 0, width, height,
                new int[] { 
                    0xFF1e5799, 
                    0xFF207cca, 
                    0xFF2989d8, 
                    0xFF207cca }, //substitute the correct colors for these
                new float[] {
                    0, 0.40f, 0.60f, 1 },
                Shader.TileMode.REPEAT);
             return linearGradient;
        }
    };
    PaintDrawable paint = new PaintDrawable();
    paint.setShape(new RectShape());
    paint.setShaderFactory(shaderFactory);
    

    and use this drawable as a background.

    You can add more than three colors in xml also by creating layers. But in XML it is quite complicated.

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

Sidebar

Related Questions

According to this link: http://msdn.microsoft.com/en-us/library/live/hh826541.aspx In order to use the Live SDK you have
According to this post in Recursive Descent vs. LALR , any LALR(k) can be
According to this article Adding use strict as the first statement¹ in your JavaScript
according to my last question i have an new belonging question. After Editing my
According to everything I've read, Firefox 3.5+ supports localStorage. And yet I'm seeing the
According to the Ruby Set class's documentation, == Returns true if two sets are
According to the MSDN Documentation for ThreadState , the Stopped state can be entered
According to the Queries and Indexes doc you can go a query effectively identically
According to this question , I should try to use Preallocation is Matlab. Now
According to the accepted answer here this is what I have to do to

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.