4

Is there a way to change color of a ninepatch image(png) programly on android ? I know how do this with bitmap but not with ninepatch...

Thanks to helping me.

Regards Jim

jaumard
  • 8,202
  • 3
  • 40
  • 63

1 Answers1

1

NinePatch images are standard PNG files, with a 1-pixel border around the outside to mark the repeated areas. You can edit them in any image editor, and as long as you leave the 1-pixel outer border alone, they'll continue to work just fine.

See here for how they are constructed.

Graham Borland
  • 60,055
  • 21
  • 138
  • 179
  • Thanks but I would like to modify it programly. Sorry I forgot to tell in the subject. – jaumard Feb 09 '11 at 15:21
  • did u get ur answer, m searching for the answer of this question – Naba Jun 14 '12 at 13:54
  • No answer I just make one ninepath in all color i want... Always search for doing this – jaumard Aug 24 '12 at 10:11
  • Did you try to apply filters or whatever to a bitmap loaded from your drawable? As long as it is a PNG you should be just fine. Proper naming may be required. I think you may need to make a [NinePatchDrawable](http://developer.android.com/reference/android/graphics/drawable/NinePatchDrawable.html) from the bitmap you updated. Then you can use [setBackgroundDrawable](http://developer.android.com/reference/android/view/View.html#setBackgroundDrawable(android.graphics.drawable.Drawable)) (deprecated since API 16 but has a replacement). – zysoft Aug 12 '14 at 19:03