Transparent 9patch image: line showing through - android

I got a transparant 9patch image which has the 9patch lines showing trough.
This is the output:
Obviously I don't want the horizontal lines to be visible.
This is how I created the 9patch:
This is the final image that is used in the application:
AFAIK the 9patch is correct. What do I need to change in order for the horizontal lines to disappear?

The unwanted lines come from the fixed (non-stretched) parts of the ninepatch overlapping. This is happening because you are drawing it at a pixel height that is smaller than the sum of the heights of the fixed sections.
As #kcoppock said above and then curiously retracted, the left hand edge should be solid black where it is vertically stretchable.

Try connecting the two dots on the left edge, making it a solid line, see if that fixes the problem. You also only need 1 dot along the top for the exact same result.
EDIT: Ignore the above, I don't know what I was thinking. Connecting the line on the left is definitely not allowed, that's my mistake.
EDIT: Ignore the above edit -- Reuben's right. :)
I don't know that it's what's causing the problem, but I noticed that along the top edge, there are some pixels that are not fully transparent (e.g. pixels(5,0) through (28,0) are a very light shade of gray) likely due to some bleeding over of the anti-aliasing of the shape. Try flattening the image, and erasing all the outermost pixels, other than the black pixels, of course. That should only cause a compiler error, though, it shouldn't cause that sort of an artifact. I wish I could test it myself right now but I can't.

Related

9patch (nine-patch) image does not stretch /scale properly

Dear Fellow Developers,
I've ran into the problem shown in the attached picture. We have been trying to tweak the dropdown menu's 9patch image provided by a graphics designer, but could not get it to work. The black stretch markers are not being hidden, and Android does not stretch it the way we would expect.
The device is a Nexus 7. We have tried several various image sizes, but none seemed to work. I am also attaching a copy of the 9patch.
What could be wrong?!
This happens:
Here is the 9patch
If the image has been created in a normal image editor rather than the android 9 patch tool, it could be just that its not done exactly right.
The image must have a 1px transparent border other than where the black lines are. Make sure its completely transparent and is only 1 px thick
Also I don't think you can have split lines (like you have down the left and right side of the image, I think they must be one solid line on each side)

Ninepatch inconsistent for arrow button

The problem with rendered images is that the left side triangle isn't smooth enough. There is a bit of jagged edge on the slopes. This was found in the draw9patch tool's preview too, but couldn't tackle it so far.
Any hint regarding solution will appreciated.
This happens because you specify too wide area for the height shrink/stretch. Put just one black pixel in the leftmost pixel column (it's tricky where to put it, actually. I'd put one pixel in the very top of your image and one more - in the very bottom).

Android draw9patch: static area gone

I uploaded a screenshot what I'm doing: http://www.fotos-hochladen.net/uploads/bildschirmfoto0knmxp974g.png
I want the yellow area to be always the same size, whereas the transparent area at the top should scale. The problem is, that the whole image gets transparent with that configuration.
If I add another dot at the left side it works, but then the yellow area also scales...
If I understand the docs correctly, this should work as I thought.
Thanks in advance.
Try un-marking the farthest right pixel along the top edge. I'm not exactly sure why this works, though.

Android / 9-patch PNG: What, if I need smth like a 11-patch PNG?

In Draw 9-patch, everything looks fine. However, my SDK says the 9-patch png is malformed. Because I have something like an 11-patch png. Because I don't want the little grabbing area to be scaled. How to get it working? The screenshot describes everything:
Error Meassage in Console:
ERROR: 9-patch image /res/drawable-hdpi/top_complete.9.png malformed.
Can't have more than one marked region along edge.
Found at pixel #10 along bottom edge.
ERROR: Failure processing PNG image /res/drawable-hdpi/top_complete.9.png
I believe your issue is that you're splitting the content area into two pieces which is not allowed. The top and left borders are treated differently by the tool than the bottom and right borders. The top and left describe what is stretchable, the bottom and right define content area (which must be contiguous).
Check the checkbox to show content area and play with it to see what I'm talking about.
I wouldn't split it into left and right, I would remove the == in the 9-patch and use this as a seperate image with center and bottom gravity so that is will always stay in the middle where you want it.
Just a hint: I always reduce the "scaled" part to 1 pixel width/height to get a minimized image.
9-Patch PNG without the grabber
XML of the Button:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:textSize="11sp"
android:id="#+id/ButtonTop"
android:background="#drawable/top_just_bg"
android:drawableBottom="#drawable/top_dropper"
android:gravity="center"
android:paddingLeft="15sp"
android:paddingRight="15sp"
android:paddingTop="3sp"
android:text="There we go! It's working... ;)"></Button>
Is the use of Padding and sp-Values alright?
Since the original problem is not solved yet: You may split your image up into two layers, one NinePatchDrawable for the stretchable part and a solid one (centered) for your static image. Then just use a LayerDrawable to draw them on top of each other. Here is a good example of how to use the appropriate <layer-list> tag. That's how to do it the right way. ;-)
Split the original image in two and use those.
That image above looks fine, and the preview shows it's seemingly ok.
What's the error message from the device when you try to use it?
Are you sure that every pixel on the edge is either entirely white or black?
Even the slightest of transparency on the edge can upset Android.
Edit:
Ah ha, the error message reveals the problem.
Only the top edge of the image determines which areas will be stretched.
Remove the black pixels on the bottom edge, assuming this is just a grab bar that will have no content (e.g. text) inside it.
Otherwise, just fill in the central gap in the bottom edge, so that text content can be displayed in the purple area.
Review all borders ... Two in top and left (will be scaled) and 1 for right and bottom (will not be scaled).

Font padding problems with Droid font in Android

I'm trying to create some 9patch images that have some text as their content. I define the stretchable area with a black pixel line top and left. And I define the content area with a black pixel line right and bottom.
However, it seems as though Droid is adding padding to the top and bottom of the content area, messing my layouts up. Has anyone else experienced this?
You say you're putting a black pixel line for the top and left? For the top, you should place just a single pixel for the stretch point. For the left, you can place either one or two pixels (two if there are two separate places you would like to stretch). Let me know if I am misunderstanding you though.

Categories

Resources