2

is there a way to have 2 gradients in a drawable xml using either a <layer-list> or <shape> or some combination of them?

2 Answers 2

7

Based on your clarification in Roman Nurik's response, I think what you're looking for is centerColor.

<gradient startColor="#00FF00" centerColor="#FFFF00" endColor="#FFFFFF"></gradient>
Sign up to request clarification or add additional context in comments.

2 Comments

what if we want to have more than 3 colors?
No, you can't have more than 3 colors in a single gradient.
0

I don't see why not... a layer list drawable that references two shape drawables sounds like it would work. Have you tried that?

2 Comments

yeah i did, it works except for one thing: there's no way to make the gradients go from 0-50% and 50% - 100% of the drawable. they only allow for absolute values.... which sucks.
Ah, I'd update the original question to be something like "how do I create gradients that have intermediate color steps." That sounds a little more clear than the original question :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.