There is no easy way to do this. You will need to manually generate a PNG image that has included in it a 9-patch chunk whose contents match the description here:
http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=include/utils/ResourceTypes.h;h=10baa11a5114a4efd3ddb1d7fc4d870d8a2e8401;hb=HEAD#l45 On Tue, Jun 21, 2011 at 6:37 AM, Jake Colman <col...@ppllc.com> wrote: > > I am trying to allow the user to specify the background color of a > ninepatch that is part of my res/drawble directory. The modified > ninepatch will then be set as the background image for my widget. I > realize that you cannot change the contents of res/drawble so I have to > write the image to temporary storage and then use setImageFromURI to > point at the modified ninepatch. > > I cannot figure out, however, how to save the image. > > I have the following code: > > Drawable bg = this.getResources().getDrawable(R.drawable.appwidget_bg); > bg.mutate(); > bg.setColorFilter( color, PorterDuff.Mode.MULTIPLY ); > > What method can I now use to write this out? There do not seem to be > any methods on Drawable that will persist an image. Is there a helper > class that I need to use? I did look at BitmapFactory but, unless I > misunderstood, it didn't seem to be the solution. > > Is there a preferred location to use for this kind of temporary file? > > Is there a better recommended way of doing what I am trying to do? > > -- > Jake Colman -- Android Tinkerer > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en