Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

9 patch converted to gradient

I would like to have on my Android application an ActionBar with a bottom line. This line should looks like this with only 4 colors : What I want

To get this effect I use a 9patch but instead of showing the 4 colors, it replaces it with a gradient : What I get

This is the 9Patch I'm using. Do you know where I'm wrong, because I don't understand why :/

What I want

Thanks for your help !

like image 856
g123k Avatar asked Mar 20 '13 10:03

g123k


2 Answers

You need to use an image like this one:

enter image description here

like image 137
Shade Avatar answered Sep 23 '22 16:09

Shade


Try editing your 9-patch so that instead of the blocks of colour being 1 pixel wide, make them 3 wide, where only the middle pixel is marked as stretchable. This might give you what you need.

It's doing it because you've marked the boundary between colours as stretchable, so when it stretches your 9-patch it interpolates the values at the boundary so that it produces a smooth transition. If you change your 9-patch to my suggestion, you'll have marked the boundaries as non-stretchable, which should remove the gradient.

like image 30
Matt Taylor Avatar answered Sep 25 '22 16:09

Matt Taylor