I am using the Android 9-patch tool to generate my 9-patch images. I have to support a number of different resolutions and button states. This means that for a single 9-patch button I need to generate 16 separate assets. Currently I am generating each of these separately using the Android 9-patch tool interface which is taking a lot of my time. If I was able to specify the 9-patch dot for a range of buttons which have the same properties this would save me a lot of time. Is there the equivalent of a command line tool or other approach which would help.
Thanks
Here is a nifty looking tool I just found. I cannot verify its accuracy or stability, but it claims to do what you want.
You can try to use the Android Asset Studio at http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html.
Well, there's is no tool as you like afair, but you could easily craft small script (PHP, Perl whatever) that would combine two images (main image + 9-patch dots) together. Or you can save dots separately and then load it into GIMP or Photoshop as layers and export as single final 9patch PNG.
Related
I have a series of images which I want to use as nine-patches to represent the different states of a button. Is there a command line tool to copy the border pixels from one .png to the next? It could save me an hour of clicking.
Android Asset Studio by Roman Nurik is set of tools to relieve some of the tasks required by Android developers and designers. For a while parts of it was in the Eclipse ADT plug-in: http://tools.android.com/recent/assetstudiointegration
Start here:
https://github.com/romannurik/AndroidAssetStudio
For Nine Patch related content you should look at Simple Nine Patch Generator:
http://romannurik.github.io/AndroidAssetStudio/nine-patches.html
and see if it is of assistance.
I've been trying to create an image button to use in my test app. Once I've imported the asset it looks grainy and pixelated, especially compared to the app_compat radio button. Here is the comparison (custom asset on left).
How can I get the edges of my custom asset to be as clean as the radio button?
You need to provide assets for various screen densities. If your app is not providing such assets directly, then Android will try to make such by usually scalling what your app provides. This usually ends with pixelated graphics. Please read this article about how all this work in Android: https://developer.android.com/guide/practices/screens_support.html
I'm a designer/developer learning Android after a year spent developing on iOS.
iOS's equivalent of NinePatch/9patch is called resizableImageWithCapInsets. It allows the developer to take a regular PNG and programmatically specify the 9patch information -- that is, the info that goes in the 1-pixel border around a .9.png file for Android.
But with one key difference. On Android, the bits in the middle of the 9patch are scaled, whereas on iOS they're tiled. For some types of images this doesn't matter; but for anything with a texture or pattern scaling destroys the image.
Specifying the regions programmatically also allows designers use of tools like http://macrabbit.com/slicy that split a complex, master Photoshop files into individual image assets; as far as I can tell there aren't currently equivalent tools for Android 9patches. (The draw9patch tool that comes with the SDK doesn't work because you'd have to reuse it every time you exported from the main Photoshop file.)
I'm guessing one could create a Drawable subclass that mimics the iOS behavior: you pass it a plain old PNG and a set of 9patch dimensions and it draws itself appropriately, tiling the middle sections. You could even provide a switch to toggle between tile and stretch (which I wish iOS did).
As a newbie it'd take me some time to figure out how to do this. Does something like it already exist as an open source component or sample?
Thanks!
I am investing some time doing drawables for an Android project and I am looking for alternatives.
Currently I do them on Adobe Illustrator and with some drawables I can use Android Asset Studio (e.g. drawables for the action menu). The problem with Android Asset Studio is the lack of possibilities to use my own color (we can only use white/black colors).
I wanted something like Android Asset Studio where I can give him a HD image and he creates all drawable sizes. Is that possible?
Another option could be a program/script that could allow me to say "I want to scale to these resolutions" and he does it for all images.
What you're looking for is called a batch resizer, but without knowing what you're working with, it's hard to give a recommendation. For instance, you can use both Photoshop and Gimp for it. I believe Gimp will require a plugin, while Photoshop has the script built-in.
Android NinePatch images seem to be standard .png files with extra information. Is there a spec for the format anywhere, as I'd like to be able to implement this on other platforms?
This is the most straightforward link I've found on the subject.
Just take a look at a 9 patch image in an image viewer. It's simply just a 1px border with black pixels flanking the stretchable areas and transparent marking the static parts.
If you zoom into this image you can see the black border marking the stretchable area:
example http://web6.twitpic.com/img/91916457-a53b6866db73378bda07c039151c69aa.4bd6119a-full.png
I would strongly suggest that you not implement the 9patch system on other platforms, for several reasons.
I have been using Android's developer tools for a year and have made extensive use of 9patch files.
They are a nightmare. PNG is not a data format, it is an image format. Mixing the two in the .9.png file is asking for trouble.
9patch files are a poor idea because they combine image and data formats into a single file that is neither fully manageable by a designer nor a developer.
Nine patch files: you will regret your involvement at some point during maintenance, support and updates phase.
Perhaps if at some future date support for 9patch files is added to a number of quality tools (for example, PS CS4 doesn't understand 9patch files as a specific format, nor does it honor the rules of valid nine patch formats.)
The existing tools for nine patch files are awful -- essentially unusable in the opinion of most designers who I have hired.
This Link is very useful for nine patch image in android.
It is very useful example in android. Only use .9 patch PNG file.
http://blogingtutorials.blogspot.com/2010/12/android-nine-patch-example.html
Modern browsers support CSS 9-path based backgrounds:
http://www.css3.info/preview/border-image/
I found this link to be very useful: link to blog post. It uses some examples for the different borders defined when a 9 patch is created. It shows how the extra information is used in scaling the images' dimensions (x,y).
There is even a nice comment by a Richard L. at the end which says how you can add regions to be protected from scaling the image by including breaks in the borders; eg. not scaling sections in the image.
Took me a while to understand that the Extension of the 9 patch file should be xxxx.9
and not xxx.9.png