I'm trying to set bigger width to my image but I need that the center part of the image remains without stretching. NinePatch assumes keeping corners from stretching, but I want something similar for the center part. I tried to set two different columns of pixels in ninePatch editor and assumed it will be symmetric scaled in both parts , but It takes in consideration only the first part, so I think libgdx ninepatch system does not allow to do that. Any ideas how to solve the problem in most convenient way?
Asked
Active
Viewed 137 times
1 Answers
0
There are no ninepatch equivalent that will allow to stretch an image without stretching a defined center part.
The simplest solution I see is using 2 images on top of each other.
- The top image: corresponds to the center part of your final image. You'll set it to the dimensions you want it to appear.
- The bottom image: corresponds to the borders of your final image. So basically it will be your final image, in which you replace the center part with blank. This bottom image will be stretched.
By combining these 2 images you'll create the illusion of an image that stretchs but with a center that keeps a constat size.

vdlmrc
- 737
- 5
- 17
-
Thanks for suggestion, I already decided not to use any workaround because I stretch the image not too much, so the picture is not distorted a lot, but I think it will be better in the future to have that functionality in libgdx. something like NinePatchCenter – Khachatur Badalyan Nov 22 '15 at 11:24