开发者

Android 9Patch resizing in photoshop

开发者 https://www.devze.com 2023-04-04 22:32 出处:网络
I have some large icons, which are 9patch, and have to create a smaller set for a smaller screen. If I use something like photoshop to do the resize, are they still 9pa开发者_高级运维tch?I just upload

I have some large icons, which are 9patch, and have to create a smaller set for a smaller screen. If I use something like photoshop to do the resize, are they still 9pa开发者_高级运维tch?


I just uploaded on code.google.com a tool that does the resizing for you :https://github.com/redwarp/9-Patch-Resizer

It's really simple : just drag n drop a xhdpi 9 patch, and it'll create the lower densities (ldpi, mdpi and hdpi).

Hope it helps !

Edit : moved to github


Nine-patch image is usual .png image with 1-pixel black border (link). I think if you may edit it PhotoShop. Note that border can't be broken.

Another way is: edit source image in PhotoShop and use Draw 9-patch tool to create 1-pixel border. It includes in standard Android SDK and it is free.


No, they are no more 9patch.

Say we resize 8x8 to 4x4, there 4 Pixels from the original made to 1 pixel(simplified). So you loose much information. When resizing from 256x256 to 255x255 the loss of information is so small, that there is a good chance for the borders to stay 9patch-compatible.

The only method to resize these images(by very small factors) is "Nearest neighbor", because all the others use interpolation of colour-values with the surrounding pixels(the black border becomes gray).

In your case of app development, i would take the time and use "the other way" from "Dmitriy_Boichenko"'s answer and do the 9patch-thing from ground up, because graphics bugs are unsightly.


you can edit 9-patch inside photoshop of course. In fact, you can edit in any editor supporting png. It's a simple PNG file in the end.

There is only 2 very important rules: File extension must be .9.png The border around the image must be one pixel wide and contain only pure black or fully transparent pixel.

There is no need to create different density if you do it well, unless you don't like the look once it is scaled up or down.

Now since you mentioned icons, I wouldn't do Icons using 9-patch. I would create 3 different density for each Icon.

Follow the guidelines here: http://developer.android.com/guide/practices/ui_guidelines/icon_design.html

0

精彩评论

暂无评论...
验证码 换一张
取 消