Edit android ninepatch png programly (change color) - android

Is there a way to change color of a ninepatch image(png) programly on android ? I know how do this with bitmap but not with ninepatch...
Thanks to helping me.
Regards
Jim

NinePatch images are standard PNG files, with a 1-pixel border around the outside to mark the repeated areas. You can edit them in any image editor, and as long as you leave the 1-pixel outer border alone, they'll continue to work just fine.
See here for how they are constructed.

Related

Android: 9-patch png is treated like a normal png

I've made this 9-patch png and added it to the res/drawable folder:
It works nice in the example eclipse shows:
But on the emulator it looks messed up:
Why is this happening and how can I fix this?
EDIT: The border on which I've placed the black dots is white, not transparent. Not sure if that's got anything to do with it...
This probably happens because you have a small mistake with the black pixels you have set.
Try to re-cut the edges of the picture and to add the black pixels all over again.
I had this problem too once and this helped me.
if the border is white then this is your problem it has to be pure black or nothing at all.
UPDATE: Try this image:
It seems you are not saved your image with .9.png
In order to make it work do like this
save your image in the following format in your drawable folder
yourimage.9.png (not png format of your image)
Check this reference draw 9 patch
The Android SDK contains a 9-patch editing tool (draw9patch.bat) that can help you to produce and/or validate 9-patch images. Without it, it is very easy to make a mistake in defining your border.
The one-pixel border should be transparent except for the black pixels that define the various parts of the image to be treated differently during scaling.

removing white pixels (alpha channel) in a png

I have an ImageView that uses a png of a coin. the png is square and everything outside of the round coin is showing as white in stead of clear. How would I accomplish this?
the corner are not transparent in you png file.
You need to make them transparent beforehand using your favorite image editor, or you can use an online service Here

Android how to set button to have transparent background but outline still there

When I set android:background="#android:color/transparent, it sets my buttons background to transparent, but the outline of the button disappears. How do I set it so that the background is transparent but there is still an outline?
You can use a custom selector that uses different nine patch image for different states of the button.
This link might be helpful
You might use this image...
I hope it helps..
One approach would be to make yourself a 9-patch that has a border but transparency in the middle.
Here is an example:
it is an 11x11 pixel square with a 2 pixel black border. If you download this png and drop it into draw9patch and add the a pixel in the middle of the left and top then include the 9patch png file in your drawables and set
android:background="#drawable/bground"
either save your 9-patch as "bground" or change that in the above line to whatever you save it as.

can any body set this image with 9-patch in android

I tried but the side round shape not shaped properly with 9-patch.
9-patch is a simple png image with 1-pixel borders indicating stretchable area. Read more.
This should solve your purpose.

Draw 9-patch not working - cannot edit image

after I found out (sadly) that there is no easy way to create a simple border around a View, I was forced to use the 9-patch-image approach to get a border around my View.
So I read the short thing there is on the 9-patch and its easy enough to understand. I started the "Draw 9-patch" application that came with the Android SDK, opened up a very simple image I created in Paint and then... I got stuck.
According to the page (http://developer.android.com/guide/developing/tools/draw9patch.html) I should be able to define those areas where the image can be expanded and so on, just by clicking on the edges ("Click within the 1-pixel perimeter to draw the lines that define the stretchable patches...").
So I try to do just that and absolutely nothing happens. I try to hold down SHIFT when clicking and also do the rigth-mouse-click, and nothing happens. When I move the mouse away from the 1-pixel perimiter I get a grey-and-red "marquee" (stripes).
Bottom line is: nothing happens no matter what I do.
The tool definitely works, but make sure the image you create first does NOT have the .9.png extension. If it does, the draw9patch tool will assume the 1 pixel perimeter of your image is already setup as 9-patch. If you open an image with just a .png extension, the tool will add the 1 pixel perimeter and you will be able to manipulate it as described, and save it as 9-patch when you're done.
The 9-patch tool is a bit awkward to use, but it does work. I believe you need to left click and drag around the edge to paint the outside border.
Alternatively, you can use any image editor and create a one pixel empty border around it, and draw in the following:
Top/Left = black pixels for the area of the image that can be grown or shrunk as needed. For a typical border, it is everything except for the curved corners
Bottom/Right = black pixels for the small snippet that should be repeated if the image needs to be grown in that direction.
You must use a non-8bit png file to create a .9.png file, or it can not be edit.
In my case, I can convert a 8-bit png to 9-patch file with Android Studio successfully, but I can't edit it anyway.
When I export the origin psd to normal png file, and convert it to 9-patch file, the 9-patch borders ban be edit now!

Categories

Resources