Problem while creating 9 patch images - android

I am creating 9 patch images using draw9patch tool and saving images with extension .9.png but when I am using created 9 patch images in app it is giving error.
But when I downloaded an 9 patch image from net & used in my same app it is working properly.
I am not getting what I am doing wrong .
Please Help

You must be creating the 9-patch wrongly. I had also the same issue . You must be drawing the black patch on one side of image. Try to draw the black patch by dragging your mouse two side of image. I hope you can understand my words...........

Nine-patch images on Android must have transparent 1-pixel edge, and have opaque pixels in left-top border (1 pixel wide) specifying which part of image is stretched, and which do not.
More here: http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch

Related

How to expand vector drawable?

I was trying to expand my shape but only from one side.
What I have:
https://imgur.com/NboRnFw
What I want to have:
https://imgur.com/eTQpA75
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="368dp"
android:height="257dp"
android:viewportWidth="368"
android:viewportHeight="257">
<path
android:pathData="M0,6H348C359.046,6 368,14.954 368,26V243H0V6Z"
android:fillColor="#E7C9FF"/>
</vector>
How can I do this in Android Studio? Is there some kind of image scaling to achieve that? I don't want to change the resource code of this shape.
For something like this, its better yo use 9 patch images. You wouldn't achieve this result any other way since changing width height ratio will make the image distorted.
You can specify the area which expands by giving it 1 pixel order, very easy to set up and there is a built in editor in Android Studio.
Make a PNG from your SVG first, then in Android Studio, right-click the PNG image you'd like to create a NinePatch image from, then click Create 9-patch file.
https://developer.android.com/studio/write/draw9patch
It takes literally a few seconds to create a 9 patch. You can also use this online editor to build a nine patch without Android Studio.
(I was trying to make your drawable into a 9 patch but it had a white background which was causing issue.)

Error:Must have one-pixel frame that is either transparent or white in Android Studio

I have just imported a project from eclipse to Android studio. Almost for every second image , android studio is giving the following error.
Error:Must have one-pixel frame that is either transparent or white.
I am trying to edit my images for last few hours, but couldn't do it. Can anyone guide me whats the best solution for it.
Why its in only Android Studio why not in Eclipse.
This is shown because you're trying to edit 9-Patch images that don't have the appropriate 1-pixel border.
Android uses an image format called 9-Patch which allows you to define stretchable areas in an image (you can read more about it here). To fix your problem, either add an outer 1-pixel thick transparent frame to your png images or simply rename them from .9.png files to .png files

9 patch image prevent build project android studio

I am moving to Gradle build . but i have this error for a lot of 9-patch images .
Note the drawable is auto generated by http://android-holo-colors.com
but they are old.
I am using android studio 0.5.1
and my build tool version is 19.0.3
this is the error
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: Failed to run command:
/Applications/Android Studio.app/sdk/build-tools/19.0.3/aapt s -i /Users/Ed/Desktop/TestAndroid/app/src/main/res/drawable-mdpi/spinner_default_holo_dark.9.png -o /Users/Ed/Desktop/TestAndroid/app/build/res/all/debug/drawable-mdpi/spinner_default_holo_dark.9.png
Error Code:
42
Output:
ERROR: 9-patch image /Users/Ed/Desktop/TestAndroid/app/src/main/res/drawable-mdpi/spinner_default_holo_dark.9.png malformed.
Frame pixels must be either solid or transparent (not intermediate alphas).
Found at pixel #3 along top edge.
/Users/Ed/Desktop/TestAndroid/app/src/main/res/drawable-hdpi/cab_background_bottom_test.9.png
Error:Ticks in transparent frame must be black or red. - ERROR: 9-patch image /Users/Ed/Desktop/TestAndroid/app/src/main/res/drawable-mdpi/spinner_default_holo_dark.9.png malformed.
Anyone faced the same problem.
Have you tried following the suggestions in the error log?
I.e. take a look at the 3rd (possibly 4th if it treats it as zero indexed?) Pixel along the top row in an image editor:
Is the pixel red or black (#FF0000 or #000000)?
Does it have an alpha value of 255 or 0?
If the answer is "no", then I guess that's your problem. This will then obviously also need to be applied to all other marker pixels around the edge of the images.
I'd add this as a comment, but don't have enough rep - sorry.
I saw a solution in other feed and the way to fix this issue is to use draw9patch tool to open the image and save it directly. I use this way to solve this issue.
About "draw9patch", you can use that tool in the tools directory of the Android sdk folder or use it directly by clicking the image within the Android Studio, it uses draw9patch as well.
My two cents,
I used photoshop to create my ninepatch and came across this error.
I had used the brush tool in brush mode with the black color to paint the border pixels (content and stretch)
The problem with the brush is that it also colors contiguous pixels with just a tiny amount of very transparent black so that you can't see it. Using the eraser in 1px crayon mode on all the pixel that should have been transparent worked for me.
When working on a nine patch in photoshop always use the brush tool in crayon mode

Scale images excluding corners to make large windows

I do have a small 100X100 texture for my game, what my question is can i scale that image excluding its corner so that i can make different size window out of it. I am attaching the image so that u will have a better understanding, any help is appreciated, thanks :hug:
Here is the tool to create 9 patch images
http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html
Try this. It should work.

Issue while using 9 patch

I have an app, that to chatting. I need to create bubbles. I did it with nine-Patch image but it was not useful because I need little triangle on right (left) of the bubble and when nine-Patch stretches the image the triangle also gets stretched. This is the problem.
Can I Draw background of Layout with canvas or etc. ?
Try this ones
download it and do not forget to rename it with image1.9.png
This may not working give me your mail id i will mail you
Also, check this one and rename it as .9.png
It was created using the draw9patch tool located in sdk\tools folder.

Categories

Resources