Creating Nine (9) Patch Png Files With Gradients
Solution 1:
Why do you want to use a 9-patch for that? 9-patches stretch an area of an image by copying/duplicating pixels. That will not work well with gradients. Have you considered using a GradientDrawable instead?
<shapeandroid:shape="rectangle"><gradientandroid:startColor="..."android:endColor="..." /></shape>
See shape drawables.
Solution 2:
As to your question about dithering, I didn't address that with my previous reply.
You'll have to enable dithering from your application code I'm afraid, as far as I know there is no way to do it from XML. You can use the setDither(true)
call on your drawable, as documented here.
This will make for much nicer gradients, since it mitigates the banding artifacts you see on gradient images. I haven't tried this on shape drawables though, just PNG files.
Also, if you're targeting Gingerbread it may be worth reading Bitmap quality, banding and dithering. Apparently they snuck a change into 2.3 which addresses these issues.
Post a Comment for "Creating Nine (9) Patch Png Files With Gradients"