Saving run-time generated NinePatch on external memory

我的梦境 提交于 2019-12-12 01:53:40

问题


I'm following this post to create nine patch drawable at run-time. I need to save the 9patch image on the internal/external memory, so that i can easily retrieve it's URI and assign it to an ImageView for example. Does anybody know how can I achieve this?

P.S. Bitmap.compress method won't work, because it will save the image as a regular (not 9patch) png file.

P.S. I know that I can serialize generated NinePatch object and save it to a file. But this way I can't assign it to a RemoteViews object (using RemoteViews.setImageViewUri method). So I need to save it as a real nine patch image.


回答1:


You can store the image as Bitmap and then create a NinePatch using http://developer.android.com/reference/android/graphics/NinePatch.html#NinePatch(android.graphics.Bitmap, byte[])



来源:https://stackoverflow.com/questions/27610790/saving-run-time-generated-ninepatch-on-external-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!