Search code examples
androidnine-patchimage-scaling

scale nine slice image android


I have a an image of a text field that I want to put as the background of my text field. I made a nine slice image so I can change the size of the image but retain the integrity of the corners. I have this image in my drawable xhdpi and I want to use the same image in my hdpi and mdpi. I need to do this for multiple images in my app so I do not want to have to make a nine slice image for each pixel density. When I drag my nine slice into photo shop to change the size of the image the black lines above and to the sid of the text box are now in the image, not a pixel above/left of my image. Is there any way that I can scale my nine slice? Or do I have to make a nine slice for each pixel density?


Solution

  • Rule of Thumb: When you scale your images for each density, watch out for aliasing problems even when the height and width are in integer multiples.

    That is: make a nine slice for each pixel density to be safe as your black dots/lines may get cut out.