Tiled alternative to 9Patch? - android

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!

Related

Android Custom Asset Pixelated

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

Android 9-patch batch

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.

Android game Image format

I have a problem with an image for an android game. The problem is not a problem with the code because the code that I use I took from a book (Beginning Android 4 Games Developer).
The problem is this: I know the format that I have to use in android: png, but I don't know the settings for this format that I have to use (like RGB565...). Because if I use simply png, when I run the game the images are not good. So I need someone to explain to which settings I need to use for images for android games.
P.S The software that I used is photoshop. If there is better software for this purpose tell me.
I think there is a strong misconception in your understanding of Android and how it implements graphics. You are not constrained to .png for nearly any of your development. The .png and .9.png are only enforced strictly for managing drawable constants.
Android uses Java and has the capability to utilize nearly any graphical format. In particular native support for .bmp, .png, and .jpg are present for every device and Android OS version. You may even create your graphics in realtime byte by byte.
As for a good image editor, there are a number out there. I often use a combination of GIMP and Photoshop, myself.
Hope this helps,
FuzzicalLogic

Generate of all drawable sizes from one (large) image automatcly

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.

Convert PSD to Android XML (layout) Format?

I am coding an Android App for a research project at my institution, and have been working with a designer who has rendered some attractive UI mockups in Photoshop (using CS5). I'd like to implement her designs as layouts for my Android application, and this would be WORLDS simpler if there were some way I could convert the files to XML format. I think it's rather counter-intuitive that PS offers android templates, but no real way to apply these in the android design/layout process, short of (attempting to) mimic her artwork in XML code, which I cannot do by any stretch. Is this conversion possible? Is there something I am missing?
Thanks
~Taichou
I'm not aware of any such tool.
But you can approximate it by slicing up her mockups and using them in your GUI like you would convert a website template from an image to HTML.
As long as her layouts aren't too terribly complex you should be able to get by with flow layouts or relative layouts.
Right click - properties - Background (in Eclipse layout design) might be what you're looking for, but remember a bitmap image won't look the same on many devices with different screen resolutions.

Categories

Resources